1#!/usr/bin/perl -w
2
3use strict;
4
5use Test::More tests => 10;
6
7use DateTime;
8
9# exercises a bug found in Perl version of _normalize_tai_seconds -
10# fixed in 0.15
11{
12    my $dt = DateTime->new( year => 2000, month => 12 );
13
14    $dt->add( months => 1 )->truncate( to => 'month' )->subtract( seconds => 1 );
15
16    is( $dt->year, 2000, 'year is 2001' );
17    is( $dt->month, 12, 'month is 12' );
18    is( $dt->hour, 23, 'hour is 23' );
19    is( $dt->minute, 59, 'minute is 59' );
20    is( $dt->second, 59, 'second is 59' );
21}
22
23{
24    my $dt = DateTime->new( year => 2000, month => 12 );
25    my $dt2 = $dt->clone->add( months => 1 )->subtract( seconds => 1 );
26
27    is( $dt2->year, 2000, 'year is 2001' );
28    is( $dt2->month, 12, 'month is 12' );
29    is( $dt2->hour, 23, 'hour is 23' );
30    is( $dt2->minute, 59, 'minute is 59' );
31    is( $dt2->second, 59, 'second is 59' );
32}
33