Lines 3-9
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 => 55; |
6 |
use Test::More tests => 71; |
7 |
use Test::MockModule; |
7 |
use Test::MockModule; |
8 |
use Time::HiRes qw/ gettimeofday /; |
8 |
use Time::HiRes qw/ gettimeofday /; |
9 |
use t::lib::Mocks; |
9 |
use t::lib::Mocks; |
Lines 215-217
is( output_pref( { dt => $dt, dateonly => 1 } ), '01/01/1900', 'dt_from_string s
Link Here
|
215 |
# fallback |
215 |
# fallback |
216 |
$dt = dt_from_string('2015-01-31 01:02:03'); |
216 |
$dt = dt_from_string('2015-01-31 01:02:03'); |
217 |
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); |
217 |
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); |
218 |
- |
218 |
|
|
|
219 |
# test formatting of date strings |
220 |
|
221 |
is( is_formatted_date_string('0000-00-00', 'iso'), 0, 'is_formatted_date_string should return 0 for 0000-00-00'); |
222 |
is( is_formatted_date_string('', 'iso'), 0, 'is_formatted_date_string should return 0 for empty string'); |
223 |
is( is_formatted_date_string('baddate', 'iso'), 0, 'is_formatted_date_string should return 0 for baddate'); |
224 |
is( is_formatted_date_string('11/06/1955', 'badformat'), 0, 'is_formatted_date_string should return 0 for unknown format'); |
225 |
|
226 |
is( is_formatted_date_string('1955-06-11', 'iso'), 1, 'is_formatted_date_string should return 1 for 1955/06/11 iso'); |
227 |
is( is_formatted_date_string('1955-06-11 12:00', 'iso'), 1, 'is_formatted_date_string should return 1 for 1955/06/11 12:00 iso'); |
228 |
is( is_formatted_date_string('11/06/1955', 'iso'), 0, 'is_formatted_date_string should return 0 for 11/06/1955 iso'); |
229 |
|
230 |
is( is_formatted_date_string('06/11/1955', 'us'), 1, 'is_formatted_date_string should return 1 for 06/11/1955 us'); |
231 |
is (is_formatted_date_string('06/11/1955 12:00', 'us'), 1, 'is_formatted_date_string should return 1 for 06/11/1955 12:00 us'); |
232 |
is( is_formatted_date_string('06-11-1955', 'us'), 0, 'is_formatted_date_string should return 0 for 06-11-1955 us'); |
233 |
|
234 |
is( is_formatted_date_string('11/06/1955', 'metric'), 1, 'is_formatted_date_string should return 1 for 06/11/1955 metric'); |
235 |
is (is_formatted_date_string('11/06/1955 12:00', 'metric'), 1, 'is_formatted_date_string should return 1 for 11/06/1955 12:00 us'); |
236 |
is( is_formatted_date_string('06-11-1955', 'metric'), 0, 'is_formatted_date_string should return 0 for 06-11-1955 metric'); |
237 |
|
238 |
is( is_formatted_date_string('32-01-1970', 'metric'), 0, 'is_formatted_date_string should return 0 for 32-01-1970 metric'); |
239 |
is( is_formatted_date_string('01-15-1970', 'metric'), 0, 'is_formatted_date_string should return 0 for 01-15-1970 metric'); |
240 |
is( is_formatted_date_string('99-99-1970', 'metric'), 0, 'is_formatted_date_string should return 0 for 99-99-1970 metric'); |