Bugzilla – Attachment 68601 Details for
Bug 19222
Why does dt_from_string not understand yyyy-mm-ddThh:mm:ss ?
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19222: Why does dt_from_string not understand yyyy-mm-ddThh:mm:ss?
Bug-19222-Why-does-dtfromstring-not-understand-yyy.patch (text/plain), 2.18 KB, created by
Nick Clemens (kidclamp)
on 2017-10-26 12:57:05 UTC
(
hide
)
Description:
Bug 19222: Why does dt_from_string not understand yyyy-mm-ddThh:mm:ss?
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-10-26 12:57:05 UTC
Size:
2.18 KB
patch
obsolete
>From 35521ba2c0e4e9dc8552513f1dae9f87b251a82c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 31 Aug 2017 14:35:55 +0200 >Subject: [PATCH] Bug 19222: Why does dt_from_string not understand > yyyy-mm-ddThh:mm:ss? > >dt_from_string disregards the time part when there is a T before it. >But note that if you print a datetime it actually prints that T. >Like: 2017-08-31T13:32:37 > >A small regex adjustment could be helpful. > >Test plan: >Run t/DateUtils.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/DateUtils.pm | 2 +- > t/DateUtils.t | 10 +++++++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index af5ce7e..6ce3dab 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -115,7 +115,7 @@ sub dt_from_string { > # Add the faculative time part [hh:mm[:ss]] > my $time_re .= qr| > ( >- \s* >+ \s*(T\s*)? > (?<hour>\d{2}) > : > (?<minute>\d{2}) >diff --git a/t/DateUtils.t b/t/DateUtils.t >index 884990b..7488dfa 100755 >--- a/t/DateUtils.t >+++ b/t/DateUtils.t >@@ -4,7 +4,7 @@ use DateTime::TimeZone; > > use C4::Context; > >-use Test::More tests => 63; >+use Test::More tests => 66; > > use Test::MockModule; > use Test::Warn; >@@ -224,6 +224,14 @@ is( output_pref( { dt => $dt, dateonly => 1 } ), '01/01/1900', 'dt_from_string s > $dt = dt_from_string('2015-01-31 01:02:03'); > is( output_pref( {dt => $dt} ), '31/01/2015 01:02', 'dt_from_string should fallback to sql format' ); > >+# When T prefixes the time (like printing a datetime) >+$dt = dt_from_string('2015-01-31T13:14:15'); >+is( $dt->hour, 13, 'Check hour from dt_from_string with T' ); >+$dt = dt_from_string('2015-01-31 T13:14:15'); >+is( $dt->minute, 14, 'Check minute from dt_from_string with \sT' ); >+$dt = dt_from_string('2015-01-31 T 13:14:15'); >+is( $dt->second, 15, 'Check second from dt_from_string with \sT\s' ); >+ > # output_pref with no parameters, single parameter (no hash) > is( output_pref(), undef, 'Call output_pref without parameters' ); > try { >-- >2.1.4
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 19222
:
66669
|
66968
| 68601