Bug 24643: Support fractional seconds
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Wed, 12 Feb 2020 16:04:07 +0000 (16:04 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 13 Feb 2020 15:56:34 +0000 (15:56 +0000)
This patch allows dt_from_string to handle RFC3339 strings containing
fractional seconds up to one thousandth of a second.

Test plan:

- Apply patch
- prove t/DateUtils.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/DateUtils.pm

index 459a5a8..ef89e30 100644 (file)
@@ -117,7 +117,7 @@ sub dt_from_string {
             (?<minute>\d{2})
             :
             (?<second>\d{2})
-            (([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))
+            (\.\d{1,3})?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))
         /xms;
     }
     elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {