View | Details | Raw Unified | Return to bug 25617
Collapse All | Expand All

(-)a/Koha/DateUtils.pm (-1 / +4 lines)
Lines 183-189 sub dt_from_string { Link Here
183
    $dt_params{minute} = 00 unless defined $dt_params{minute};
183
    $dt_params{minute} = 00 unless defined $dt_params{minute};
184
    $dt_params{second} = 00 unless defined $dt_params{second};
184
    $dt_params{second} = 00 unless defined $dt_params{second};
185
185
186
    $dt_params{hour} += 12 if $ampm && $ampm eq 'PM';
186
    if ( $ampm && $ampm eq 'PM' ) {
187
        $dt_params{hour} += 12;
188
        $dt_params{hour} %= 24;
189
    }
187
190
188
    my $dt = eval {
191
    my $dt = eval {
189
        DateTime->new(
192
        DateTime->new(
(-)a/t/DateUtils.t (-3 / +11 lines)
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 => 78;
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 12: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 12:02', 'dt_from_string ' );
265
266
t::lib::Mocks::mock_preference('TimeFormat', '12hr');
267
$dt = DateTime->new( year => 2020, month => 5, day => 28, hour => 12, minute => 49 );
268
my $output = output_pref({ dt => $dt, dateformat => 'iso' });
269
$dt = dt_from_string( $output, 'iso' );
270
t::lib::Mocks::mock_preference('TimeFormat', '24hr');
262
271
263
# output_pref with no parameters, single parameter (no hash)
272
# output_pref with no parameters, single parameter (no hash)
264
is( output_pref(), undef, 'Call output_pref without parameters' );
273
is( output_pref(), undef, 'Call output_pref without parameters' );
265
- 

Return to bug 25617