Bugzilla – Attachment 116303 Details for
Bug 24850
Koha::DateUtils ignores offsets in RFC3339 datetimes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24850: Always return 'instance' local time
Bug-24850-Always-return-instance-local-time.patch (text/plain), 1.89 KB, created by
David Cook
on 2021-02-04 03:51:37 UTC
(
hide
)
Description:
Bug 24850: Always return 'instance' local time
Filename:
MIME Type:
Creator:
David Cook
Created:
2021-02-04 03:51:37 UTC
Size:
1.89 KB
patch
obsolete
>From dd59675e172a1dc52e12b53d6bcca14dd8df019a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 17 Mar 2020 10:22:16 +0000 >Subject: [PATCH] Bug 24850: Always return 'instance' local time > >This patch adds handling to ensure we always convert a passed in time to >the instance configured timezone.. > >Signed-off-by: David Cook <dcook@prosentient.com.au> >--- > Koha/DateUtils.pm | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index 913e0dabf4..958cd5f3bb 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -54,7 +54,8 @@ sub dt_from_string { > return if $date_string and $date_string =~ m|^0000-0|; > > my $do_fallback = defined($date_format) ? 0 : 1; >- $tz = C4::Context->tz unless $tz;; >+ my $server_tz = C4::Context->tz; >+ $tz = C4::Context->tz unless $tz; > > return DateTime->now( time_zone => $tz ) unless $date_string; > >@@ -120,6 +121,9 @@ sub dt_from_string { > (?<second>\d{2}) > (\.\d{1,3})?(([Zz]$)|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9]))) > /xms; >+ >+ # Default to UTC (when 'Z' is passed) for inbound timezone. >+ $tz = DateTime::TimeZone->new( name => 'UTC' ); > } > elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) { > # iso or sql format are yyyy-dd-mm[ hh:mm:ss]" >@@ -162,6 +166,7 @@ sub dt_from_string { > ); > $ampm = $+{ampm}; > if ( $+{offset} ) { >+ # If offset given, set inbound timezone using it. > $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} ); > } > } elsif ( $do_fallback && $date_string =~ $fallback_re ) { >@@ -211,6 +216,7 @@ sub dt_from_string { > ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ), > ); > } >+ $dt->set_time_zone($server_tz); > return $dt; > } > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24850
:
100585
|
100586
|
100587
|
100592
|
100593
|
100594
|
100595
|
100678
|
100679
|
100680
|
100681
|
100881
|
100901
|
100902
|
100903
|
100904
|
100905
|
101803
|
101804
|
101805
|
101806
|
101807
|
101808
|
101837
|
101838
|
101839
|
101840
|
101841
|
101842
|
101843
|
101844
|
115851
|
115852
|
115853
|
115854
|
115855
|
115856
|
115857
|
116299
|
116300
|
116301
|
116302
|
116303
|
116304
|
116305
|
116355
|
116356
|
116357
|
116358
|
116359
|
116360
|
116361
|
116511
|
126182
|
126183
|
126184
|
126185
|
126186
|
126187
|
126188
|
126189
|
127231
|
127232
|
127235
|
127236
|
127239
|
127240
|
127241
|
127242
|
127243
|
127244