Lines 4-10
use DateTime::TimeZone;
Link Here
|
4 |
|
4 |
|
5 |
use C4::Context; |
5 |
use C4::Context; |
6 |
|
6 |
|
7 |
use Test::More tests => 63; |
7 |
use Test::More tests => 67; |
8 |
|
8 |
|
9 |
use Test::MockModule; |
9 |
use Test::MockModule; |
10 |
use Test::Warn; |
10 |
use Test::Warn; |
Lines 46-51
cmp_ok $date_string, 'eq', '2011-06-16 12:00', 'iso output';
Link Here
|
46 |
$date_string = output_pref({ dt => $dt, dateformat => 'iso', timeformat => '12hr' }); |
46 |
$date_string = output_pref({ dt => $dt, dateformat => 'iso', timeformat => '12hr' }); |
47 |
cmp_ok $date_string, 'eq', '2011-06-16 12:00 PM', 'iso output 12hr'; |
47 |
cmp_ok $date_string, 'eq', '2011-06-16 12:00 PM', 'iso output 12hr'; |
48 |
|
48 |
|
|
|
49 |
$date_string = output_pref({ dt => $dt, dateformat => 'rfc3339' }); |
50 |
like($date_string, qr/2011-06-16T12:00:00\+|-\d\d:\d\d/, 'RFC3339 output'); |
51 |
|
49 |
# "notime" doesn't actually mean anything in this context, but we |
52 |
# "notime" doesn't actually mean anything in this context, but we |
50 |
# can't pass undef or output_pref will try to access the database |
53 |
# can't pass undef or output_pref will try to access the database |
51 |
$date_string = output_pref({ dt => $dt, dateformat => 'iso', timeformat => 'notime', dateonly => 1 }); |
54 |
$date_string = output_pref({ dt => $dt, dateformat => 'iso', timeformat => 'notime', dateonly => 1 }); |
Lines 114-119
isa_ok( $dt0, 'DateTime',
Link Here
|
114 |
'dt_from_string returns a DateTime object passed a zero iso day' ); |
117 |
'dt_from_string returns a DateTime object passed a zero iso day' ); |
115 |
cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects iso day 0' ); |
118 |
cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects iso day 0' ); |
116 |
|
119 |
|
|
|
120 |
$dt0 = dt_from_string( '2012-01-00T12:00:00Z', 'rfc3339' ); |
121 |
isa_ok( $dt0, 'DateTime', |
122 |
'dt_from_string returns a DateTime object passed a zero rfc3339 day' ); |
123 |
cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects rfc3339 day 0' ); |
124 |
|
117 |
# Return undef if passed mysql 0 dates |
125 |
# Return undef if passed mysql 0 dates |
118 |
$dt0 = dt_from_string( '0000-00-00', 'iso' ); |
126 |
$dt0 = dt_from_string( '0000-00-00', 'iso' ); |
119 |
is( $dt0, undef, "undefined returned for 0 iso date" ); |
127 |
is( $dt0, undef, "undefined returned for 0 iso date" ); |
Lines 198-203
$dt = eval { dt_from_string( '31/01/2015', 'iso' ); };
Link Here
|
198 |
is( ref($dt), '', '31/01/2015 is not a correct date in iso format' ); |
206 |
is( ref($dt), '', '31/01/2015 is not a correct date in iso format' ); |
199 |
$dt = eval { dt_from_string( '01/01/2015', 'iso' ); }; |
207 |
$dt = eval { dt_from_string( '01/01/2015', 'iso' ); }; |
200 |
is( ref($dt), '', '01/01/2015 is not a correct date in iso format' ); |
208 |
is( ref($dt), '', '01/01/2015 is not a correct date in iso format' ); |
|
|
209 |
$dt = eval { dt_from_string( '01/01/2015', 'rfc3339' ); }; |
210 |
is( ref($dt), '', '01/01/2015 is not a correct date in rfc3339 format' ); |
201 |
$dt = eval { dt_from_string( '31/01/2015', 'us' ); }; |
211 |
$dt = eval { dt_from_string( '31/01/2015', 'us' ); }; |
202 |
is( ref($dt), '', '31/01/2015 is not a correct date in us format' ); |
212 |
is( ref($dt), '', '31/01/2015 is not a correct date in us format' ); |
203 |
$dt = dt_from_string( '01/01/2015', 'us' ); |
213 |
$dt = dt_from_string( '01/01/2015', 'us' ); |
204 |
- |
|
|