Lines 5-11
use DateTime;
Link Here
|
5 |
use DateTime::TimeZone; |
5 |
use DateTime::TimeZone; |
6 |
|
6 |
|
7 |
use C4::Context; |
7 |
use C4::Context; |
8 |
use Test::More tests => 31; |
8 |
use Test::More tests => 27; |
9 |
use Test::MockModule; |
9 |
use Test::MockModule; |
10 |
|
10 |
|
11 |
BEGIN { use_ok('Koha::DateUtils'); } |
11 |
BEGIN { use_ok('Koha::DateUtils'); } |
Lines 67-82
cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'metric output';
Link Here
|
67 |
$date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => 'notime', dateonly => 1 }); |
67 |
$date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => 'notime', dateonly => 1 }); |
68 |
cmp_ok $date_string, 'eq', '16/06/2011', 'metric output (date only)'; |
68 |
cmp_ok $date_string, 'eq', '16/06/2011', 'metric output (date only)'; |
69 |
|
69 |
|
70 |
$date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => '24hr' }); |
|
|
71 |
cmp_ok $date_string, 'eq', '16/06/2011 12:00', |
72 |
'output_pref_due preserves non midnight HH:SS'; |
73 |
|
74 |
$dt->set_hour(23); |
75 |
$dt->set_minute(59); |
76 |
$date_string = output_pref_due({ dt => $dt, dateformat => 'metric', timeformat => '24hr' }); |
77 |
cmp_ok $date_string, 'eq', '16/06/2011', |
78 |
'output_pref_due truncates HH:SS at midnight'; |
79 |
|
80 |
my $dear_dirty_dublin = DateTime::TimeZone->new( name => 'Europe/Dublin' ); |
70 |
my $dear_dirty_dublin = DateTime::TimeZone->new( name => 'Europe/Dublin' ); |
81 |
my $new_dt = dt_from_string( '16/06/2011', 'metric', $dear_dirty_dublin ); |
71 |
my $new_dt = dt_from_string( '16/06/2011', 'metric', $dear_dirty_dublin ); |
82 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' ); |
72 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' ); |
Lines 118-131
cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' );
Link Here
|
118 |
$formatted = format_sqldatetime( undef, 'metric' ); |
108 |
$formatted = format_sqldatetime( undef, 'metric' ); |
119 |
cmp_ok( $formatted, 'eq', q{}, |
109 |
cmp_ok( $formatted, 'eq', q{}, |
120 |
'format_sqldatetime formats undef as empty string' ); |
110 |
'format_sqldatetime formats undef as empty string' ); |
121 |
|
|
|
122 |
$formatted = format_sqlduedatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); |
123 |
cmp_ok( |
124 |
$formatted, 'eq', |
125 |
'16/06/2011 12:00', |
126 |
'format_sqlduedatetime conversion for hourly loans' |
127 |
); |
128 |
|
129 |
$formatted = format_sqlduedatetime( '2011-06-16 23:59:07', 'metric', '24hr' ); |
130 |
cmp_ok( $formatted, 'eq', '16/06/2011', |
131 |
'format_sqlduedatetime conversion for daily loans' ); |
132 |
- |