diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 43581378b5..001d7abdd6 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -129,7 +129,10 @@ sub output_pref { return unless defined $dt; # FIXME: see bug 13242 => no TZ for dates 'infinite' - $dt->set_time_zone( C4::Context->tz ) if $dt->ymd !~ /^9999/; + if ( $dt->ymd !~ /^9999/ ) { + my $tz = $dateonly ? DateTime::TimeZone->new(name => 'floating') : C4::Context->tz; + $dt->set_time_zone( $tz ); + } my $pref = defined $force_pref ? $force_pref : C4::Context->preference('dateformat'); diff --git a/Koha/Template/Plugin/KohaDates.pm b/Koha/Template/Plugin/KohaDates.pm index 37d03af52d..b4c1d8d1e1 100644 --- a/Koha/Template/Plugin/KohaDates.pm +++ b/Koha/Template/Plugin/KohaDates.pm @@ -29,7 +29,10 @@ sub filter { my ( $self, $text, $args, $config ) = @_; return "" unless $text; $config->{with_hours} //= 0; - my $dt = dt_from_string( $text, 'iso' ); + + my $tz = DateTime::TimeZone->new(name => 'floating') unless $config->{with_hours}; + my $dt = dt_from_string( $text, 'iso', $tz ); + return $config->{as_due_date} ? output_pref({ dt => $dt, as_due_date => 1 }) : output_pref({ dt => $dt, dateonly => !$config->{with_hours} });