5 use DateTime::TimeZone;
8 use Test::More tests => 9; # last test to print
10 BEGIN { use_ok('Koha::DateUtils'); }
12 my $tz = C4::Context->tz;
14 isa_ok( $tz, 'DateTime::TimeZone', 'Context returns timezone object' );
16 my $testdate_iso = '2011-06-16'; # Bloomsday 2011
17 my $dt = dt_from_string( $testdate_iso, 'iso' );
19 isa_ok( $dt, 'DateTime', 'dt_from_string returns a DateTime object' );
21 cmp_ok( $dt->ymd(), 'eq', $testdate_iso, 'Returned object matches input' );
26 my $date_string = output_pref( $dt, 'iso' );
27 cmp_ok $date_string, 'eq', '2011-06-16 12:00', 'iso output';
29 $date_string = output_pref( $dt, 'us' );
30 cmp_ok $date_string, 'eq', '06/16/2011 12:00', 'us output';
32 # metric should return the French Revolutionary Calendar Really
33 $date_string = output_pref( $dt, 'metric' );
34 cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'metric output';
36 my $dear_dirty_dublin = DateTime::TimeZone->new( name => 'Europe/Dublin');
37 my $new_dt = dt_from_string('16/06/2011', 'metric', $dear_dirty_dublin);
39 isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' );
41 cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'Returned Dublin object matches input' );