Lines 1-12
Link Here
|
1 |
use strict; |
1 |
use Modern::Perl; |
2 |
use warnings; |
|
|
3 |
use 5.010; |
4 |
use DateTime; |
2 |
use DateTime; |
5 |
use DateTime::TimeZone; |
3 |
use DateTime::TimeZone; |
6 |
|
4 |
|
7 |
use C4::Context; |
5 |
use C4::Context; |
8 |
use Test::More tests => 34; |
6 |
use Test::More tests => 41; |
9 |
use Test::MockModule; |
7 |
use Test::MockModule; |
|
|
8 |
use Time::HiRes qw/ gettimeofday /; |
10 |
|
9 |
|
11 |
BEGIN { use_ok('Koha::DateUtils'); } |
10 |
BEGIN { use_ok('Koha::DateUtils'); } |
12 |
|
11 |
|
Lines 77-82
isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' );
Link Here
|
77 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, |
76 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, |
78 |
'Returned Dublin object matches input' ); |
77 |
'Returned Dublin object matches input' ); |
79 |
|
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 dt_from_string() for $_ with TZ in less than 1s"; |
84 |
$duration = gettimeofday(); |
85 |
output_pref( { dt => $new_dt } ); |
86 |
$duration = gettimeofday() - $duration; |
87 |
cmp_ok $duration, '<', 1, "Create DateTime with output_pref() for $_ with TZ in less than 1s"; |
88 |
} |
89 |
|
80 |
$new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); |
90 |
$new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); |
81 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); |
91 |
isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); |
82 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'sql returns correct date' ); |
92 |
cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'sql returns correct date' ); |
Lines 106-111
cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects iso day 0' );
Link Here
|
106 |
$dt0 = dt_from_string( '0000-00-00', 'iso' ); |
116 |
$dt0 = dt_from_string( '0000-00-00', 'iso' ); |
107 |
is( $dt0, undef, "undefined returned for 0 iso date" ); |
117 |
is( $dt0, undef, "undefined returned for 0 iso date" ); |
108 |
|
118 |
|
|
|
119 |
# Return undef if passed mysql 9999-* date |
120 |
my $dt9999 = dt_from_string( '9999-12-31' ); |
121 |
is( $dt9999->ymd(), '9999-12-31', "dt_from_string should return a DateTime object for 9999-12-31" ); |
122 |
|
109 |
my $formatted = format_sqldatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); |
123 |
my $formatted = format_sqldatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); |
110 |
cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' ); |
124 |
cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' ); |
111 |
|
125 |
|
112 |
- |
|
|