|
Lines 3-10
use DateTime;
Link Here
|
| 3 |
use DateTime::TimeZone; |
3 |
use DateTime::TimeZone; |
| 4 |
|
4 |
|
| 5 |
use C4::Context; |
5 |
use C4::Context; |
| 6 |
use Test::More tests => 35; |
6 |
use Test::More tests => 38; |
| 7 |
use Test::MockModule; |
7 |
use Test::MockModule; |
|
|
8 |
use Time::HiRes qw/ gettimeofday /; |
| 8 |
|
9 |
|
| 9 |
BEGIN { use_ok('Koha::DateUtils'); } |
10 |
BEGIN { use_ok('Koha::DateUtils'); } |
| 10 |
|
11 |
|
|
Lines 75-80
isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' );
Link Here
|
| 75 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, |
76 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, |
| 76 |
'Returned Dublin object matches input' ); |
77 |
'Returned Dublin object matches input' ); |
| 77 |
|
78 |
|
|
|
79 |
for ( qw/ 2014-01-01 2100-01-01 9999-01-01 / ) { |
| 80 |
my $duration = gettimeofday(); |
| 81 |
$new_dt = dt_from_string($_, 'iso', $dear_dirty_dublin); |
| 82 |
$duration = gettimeofday() - $duration; |
| 83 |
cmp_ok $duration, '<', 1, "Create DateTime $_ with TZ in less than 1s"; |
| 84 |
} |
| 85 |
|
| 78 |
$new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); |
86 |
$new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); |
| 79 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); |
87 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); |
| 80 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'sql returns correct date' ); |
88 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'sql returns correct date' ); |
|
Lines 147-149
$date_string = output_pref({ dt => $dt, dateformat => 'metric', timeformat => '2
Link Here
|
| 147 |
cmp_ok $date_string, 'eq', '11/12/2013 18:35', 'as_due_date with hours and timeformat 24hr (non-midnight time)'; |
155 |
cmp_ok $date_string, 'eq', '11/12/2013 18:35', 'as_due_date with hours and timeformat 24hr (non-midnight time)'; |
| 148 |
$date_string = output_pref({ dt => $dt, dateformat => 'us', timeformat => '12hr', as_due_date => 1 }); |
156 |
$date_string = output_pref({ dt => $dt, dateformat => 'us', timeformat => '12hr', as_due_date => 1 }); |
| 149 |
cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)'; |
157 |
cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and timeformat 12hr (non-midnight time)'; |
| 150 |
- |
158 |
|
|
|
159 |
|