Subject: | Enhancement for Date::Parse |
Graham,
Date::Parse 2.23 appears not to understand the ISO format for UTC time, where a capital 'Z' is appended to the time, instead of +00 or something.
The accompanying patch is meant to fix this.
I verified nothing breaks for the test suite in "t/date.t" and appended the following tests:
20020722T100000Z
Jul 22 10:00:00 UTC 2002
10:00:00Z
10:00:00
10:00
10:00 +100
10:00 +0100
These all pass; not sure if we need more tests...
Cheers,
Joe.
*** Parse.pm.BAK Thu Jun 6 20:12:58 2002
--- Parse.pm Mon Jul 22 15:45:05 2002
*************** sub {
*** 88,101 ****
$dtstr =~ s#($daypat)\s*(den\s)?# #o;
# Time: 12:00 or 12:00:00 with optional am/pm
! if ($dtstr =~ s/(?:^|\s)(\d{4})([-:]?)(\d\d?)\2(\d\d?)(?:[Tt ](\d\d?)(?:([-:]?)(\d\d?)(?:\6(\d\d?)(?:[.,]\d+)?)?)?)?\b/ /) {
($year,$month,$day,$hh,$mm,$ss) = ($1,$3-1,$4,$5,$7,$8);
}
else {
! if ($dtstr =~ s#[:\s](\d\d?):(\d\d?)(:(\d\d?)(?:\.\d+)?)?\s*(?:([ap])\.?m?\.?)?\s# #o) {
($hh,$mm,$ss) = ($1,$2,$4 || 0);
$merid = $ampm{$5} if $5;
}
# Time: 12 am
--- 88,103 ----
$dtstr =~ s#($daypat)\s*(den\s)?# #o;
# Time: 12:00 or 12:00:00 with optional am/pm
! if ($dtstr =~ s/(?:^|\s)(\d{4})([-:]?)(\d\d?)\2(\d\d?)(?:[Tt ](\d\d?)(?:([-:]?)(\d\d?)(?:\6(\d\d?)(?:[.,]\d+)?)?)?)?([Zz])?\b/ /) {
($year,$month,$day,$hh,$mm,$ss) = ($1,$3-1,$4,$5,$7,$8);
+ $dtstr .= "+00 " if $9;
}
else {
! if ($dtstr =~ s#[:\s](\d\d?):(\d\d?)(:(\d\d?)(?:\.\d+)?)?\s*(?:([ap])\.?m?\.?)?([Zz])?\s# #o) {
($hh,$mm,$ss) = ($1,$2,$4 || 0);
$merid = $ampm{$5} if $5;
+ $dtstr .= "+00 " if $6;
}
# Time: 12 am