[Koha-patches] [PATCH 91/92] Dates : improvements string recognition
Henri-Damien LAURENT
henridamien.laurent at biblibre.com
Tue Dec 22 01:21:24 CET 2009
Dates can now have one digit for month and day
---
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 7563b51..451e2d3 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 1e71677..0f0cbc2 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',
--
1.6.3.3
More information about the Koha-patches
mailing list