Bugzilla – Attachment 101840 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: Correct offset handling in dt_from_string
Bug-24850-Correct-offset-handling-in-dtfromstring.patch (text/plain), 2.04 KB, created by
Agustín Moyano
on 2020-03-26 13:45:21 UTC
(
hide
)
Description:
Bug 24850: Correct offset handling in dt_from_string
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-03-26 13:45:21 UTC
Size:
2.04 KB
patch
obsolete
>From bd62891db11eaf5fba57c014ad95b08dbd21b9f0 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 11 Mar 2020 15:59:19 +0000 >Subject: [PATCH] Bug 24850: Correct offset handling in dt_from_string > >This patch adds correct handling for when an offset is passed within an >RFC3339 formatted datetime. > >Test plan >1/ Run the DateUtils test and varify it now passes. > >Signed-off-by: Agustin Moyano <agustinmoyano@theke.io> >--- > Koha/DateUtils.pm | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index c20256c21d..cc474a6ddb 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -117,7 +117,7 @@ sub dt_from_string { > (?<minute>\d{2}) > : > (?<second>\d{2}) >- (\.\d{1,3})?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9])) >+ (\.\d{1,3})?(([Zz])|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9]))) > /xms; > } > elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) { >@@ -154,6 +154,9 @@ sub dt_from_string { > minute => $+{minute}, > second => $+{second}, > ); >+ if ( $+{offset} ) { >+ $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} ); >+ } > } elsif ( $date_string =~ $fallback_re ) { > %dt_params = ( > year => $+{year}, >@@ -180,7 +183,7 @@ sub dt_from_string { > DateTime->new( > %dt_params, > # No TZ for dates 'infinite' => see bug 13242 >- ( $dt_params{year} < 9999 ? ( time_zone => $tz->name ) : () ), >+ ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ), > ); > }; > if ($@) { >@@ -188,7 +191,7 @@ sub dt_from_string { > $dt = DateTime->new( > %dt_params, > # No TZ for dates 'infinite' => see bug 13242 >- ( $dt_params{year} < 9999 ? ( time_zone => $tz->name ) : () ), >+ ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ), > ); > } > return $dt; >-- >2.25.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