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 => 76; |
7 |
use Test::More tests => 79; |
8 |
|
8 |
|
9 |
use Test::MockModule; |
9 |
use Test::MockModule; |
10 |
use Test::Warn; |
10 |
use Test::Warn; |
Lines 258-264
$dt = dt_from_string('2015-01-31 01:02 PM');
Link Here
|
258 |
is( output_pref( {dt => $dt} ), '31/01/2015 13:02', 'dt_from_string ' ); |
258 |
is( output_pref( {dt => $dt} ), '31/01/2015 13:02', 'dt_from_string ' ); |
259 |
$dt = dt_from_string('2015-01-31 01:02:03 PM'); |
259 |
$dt = dt_from_string('2015-01-31 01:02:03 PM'); |
260 |
is( output_pref( {dt => $dt} ), '31/01/2015 13:02', 'dt_from_string ' ); |
260 |
is( output_pref( {dt => $dt} ), '31/01/2015 13:02', 'dt_from_string ' ); |
261 |
|
261 |
$dt = dt_from_string('2015-01-31 12:02 AM'); |
|
|
262 |
is( output_pref( {dt => $dt} ), '31/01/2015 00:02', 'dt_from_string ' ); |
263 |
$dt = dt_from_string('2015-01-31 12:02:03 AM'); |
264 |
is( output_pref( {dt => $dt} ), '31/01/2015 00:02', 'dt_from_string ' ); |
265 |
|
266 |
subtest 'TimeFormat 12hr' => sub { |
267 |
plan tests => 4; |
268 |
|
269 |
$dt = DateTime->new( year => 2020, month => 5, day => 28, hour => 12, minute => 49 ); |
270 |
t::lib::Mocks::mock_preference('TimeFormat', '12hr'); |
271 |
my $output = output_pref({ dt => $dt, dateformat => 'iso' }); |
272 |
$dt = dt_from_string( $output, 'iso' ); |
273 |
is( output_pref( {dt => $dt} ), '28/05/2020 12:49 PM' ); |
274 |
t::lib::Mocks::mock_preference('TimeFormat', '24hr'); |
275 |
is( output_pref( {dt => $dt} ), '28/05/2020 12:49' ); |
276 |
|
277 |
$dt = DateTime->new( year => 2020, month => 5, day => 28, hour => 0, minute => 49 ); |
278 |
t::lib::Mocks::mock_preference('TimeFormat', '12hr'); |
279 |
$output = output_pref({ dt => $dt, dateformat => 'iso' }); |
280 |
$dt = dt_from_string( $output, 'iso' ); |
281 |
is( output_pref( {dt => $dt} ), '28/05/2020 12:49 AM' ); |
282 |
t::lib::Mocks::mock_preference('TimeFormat', '24hr'); |
283 |
is( output_pref( {dt => $dt} ), '28/05/2020 00:49' ); |
284 |
}; |
262 |
|
285 |
|
263 |
# output_pref with no parameters, single parameter (no hash) |
286 |
# output_pref with no parameters, single parameter (no hash) |
264 |
is( output_pref(), undef, 'Call output_pref without parameters' ); |
287 |
is( output_pref(), undef, 'Call output_pref without parameters' ); |
265 |
- |
|
|