root/lang/perl/DateTime-Lite/trunk/t/02last_day.t @ 24134

Revision 24134, 1.1 kB (checked in by daisuke, 5 years ago)

initial import

Line 
1#!/usr/bin/perl -w
2
3use strict;
4
5use Test::More tests => 73;
6
7use DateTime::Lite;
8
9my @last = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
10my @leap_last = @last;
11$leap_last[1]++;
12
13foreach my $month (1..12)
14{
15    my $dt = DateTime::Lite->last_day_of_month( year  => 2001,
16                                          month => $month,
17                                          time_zone => 'UTC',
18                                        );
19
20    is( $dt->year, 2001, 'check year' );
21    is( $dt->month, $month, 'check month' );
22    is( $dt->day, $last[ $month - 1 ], 'check day' );
23}
24
25foreach my $month (1..12)
26{
27    my $dt = DateTime::Lite->last_day_of_month( year  => 2004,
28                                          month => $month,
29                                          time_zone => 'UTC',
30                                        );
31
32    is( $dt->year, 2004, 'check year' );
33    is( $dt->month, $month, 'check month' );
34    is( $dt->day, $leap_last[ $month - 1 ], 'check day' );
35}
36
37{
38    eval { DateTime::Lite->last_day_of_month( year => 2000, month => 1, nanosecond => 2000 ) };
39    is( $@, '',
40        "last_day_of_month should accept nanosecond" );
41}
Note: See TracBrowser for help on using the browser.