From 33f558054620a30dfc7a132ef16336c8f6ff5547 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Fri, 4 Dec 2009 14:32:21 +0100 Subject: [PATCH] Dates : improvements --- C4/Dates.pm | 6 +++--- t/Dates.t | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/C4/Dates.pm b/C4/Dates.pm index 7563b51714..451e2d34b7 100644 --- a/C4/Dates.pm +++ b/C4/Dates.pm @@ -70,10 +70,10 @@ sub regexp ($;$) { # way of saying "does this string match *whatever* format that Dates object is?" ($format eq 'sql') and - return qr/^(\d{4})(\d{2})(\d{2})(?:\s{4}(\d{2})(\d{2})(\d{2}))?/; + return qr/^(\d{4})(\d{1,2})(\d{1,2})(?:\s{4}(\d{2})(\d{2})(\d{2}))?/; ($format eq 'iso') and - return qr/^(\d{4})$delim(\d{2})$delim(\d{2})(?:(?:\s{1}|T)(\d{2})\:?(\d{2})\:?(\d{2}))?Z?/; - return qr/^(\d{2})$delim(\d{2})$delim(\d{4})(?:\s{1}(\d{2})\:?(\d{2})\:?(\d{2}))?/; # everything else + return qr/^(\d{4})$delim(\d{1,2})$delim(\d{1,2})(?:(?:\s{1}|T)(\d{2})\:?(\d{2})\:?(\d{2}))?Z?/; + return qr/^(\d{1,2})$delim(\d{1,2})$delim(\d{4})(?:\s{1}(\d{1,2})\:?(\d{1,2})\:?(\d{1,2}))?/; # everything else } sub dmy_map ($$) { diff --git a/t/Dates.t b/t/Dates.t index 1e71677d50..0f0cbc202f 100644 --- a/t/Dates.t +++ b/t/Dates.t @@ -19,8 +19,8 @@ sub describe ($$) { # Keep the number of test elements per [array] equal or the predicted number of tests # needs to be different for different (fake) sysprefs. my %thash = ( - iso => ['2001-01-01','1989-09-21','1952-01-00', '1989-09-21 13:46:02'], - metric => ["01-01-2001",'21-09-1989','00-01-1952', '21-09-1989 13:46:02'], + iso => ['2001-1-1','1989-9-21','1952-1-0', '1989-9-21 13:46:02','2001-01-01','1989-09-21','1952-01-00', '1989-09-21 13:46:02'], + metric => ["1-1-2001",'21-9-1989','00-1-1952', '21-9-1989 13:46:02',"01-01-2001",'21-09-1989','00-01-1952', '21-09-1989 13:46:02'], us => ["01-01-2001",'09-21-1989','01-00-1952', '09-21-1989 13:46:02'], sql => ['20010101 010101', '19890921 143907', -- 2.39.5