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

(-)a/Koha/DateUtils.pm (-1 / +1 lines)
Lines 219-225 sub output_pref { Link Here
219
        carp "Invalid date '$str' passed to output_pref\n" if $@;
219
        carp "Invalid date '$str' passed to output_pref\n" if $@;
220
    }
220
    }
221
221
222
    return unless defined $dt;
222
    return unless defined $dt && ref($dt) eq 'DateTime';
223
223
224
    # FIXME: see bug 13242 => no TZ for dates 'infinite'
224
    # FIXME: see bug 13242 => no TZ for dates 'infinite'
225
    if ( $dt->ymd !~ /^9999/ ) {
225
    if ( $dt->ymd !~ /^9999/ ) {
(-)a/t/DateUtils.t (-2 / +8 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 => 60;
7
use Test::More tests => 63;
8
8
9
use Test::MockModule;
9
use Test::MockModule;
10
use Test::Warn;
10
use Test::Warn;
Lines 222-227 is( output_pref( { dt => $dt, dateonly => 1 } ), '01/01/1900', 'dt_from_string s Link Here
222
$dt = dt_from_string('2015-01-31 01:02:03');
222
$dt = dt_from_string('2015-01-31 01:02:03');
223
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' );
223
is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' );
224
224
225
# output_pref with no parameters, single parameter (no hash)
226
is( output_pref(), undef, 'output_pref without parameters' );
227
is( output_pref( 'no_dt' ), undef, 'Passed single invalid dt to output_pref' );
228
229
# pass invalid dt via hash
230
is( output_pref({ dt => 'no_dt' }), undef, 'Passed invalid dt in hash to output_pref' );
231
225
# output_pref with str parameter
232
# output_pref with str parameter
226
is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' );
233
is( output_pref( { 'str' => $testdate_iso, dateformat => 'iso', dateonly => 1 } ), $testdate_iso, 'output_pref should handle correctly the iso parameter' );
227
my $output_for_invalid_date;
234
my $output_for_invalid_date;
228
- 

Return to bug 17502