Subject: | Time::ParseDate doesn't properly handle ISO 8601 dates |
comments on patches:
tweak 1 is to allow a colon between offset hour and minutes
tweak 2 is to allow an optional 'T' to separate the time and date
tweak 3 is to remove the restriction on number of digits allowed for
fractions of seconds and to also allow a comma as a delimiter
references: http://www.cl.cam.ac.uk/~mgk25/iso-time.html and
http://www.w3.org/TR/1998/NOTE-datetime-19980827
*** ParseDate.pm Mon Nov 5 07:51:13 2001
--- /home/rayg/ParseDate.pm Mon Nov 5 07:35:09 2001
***************
*** 391,397 ****
{
my($offset) = @_;
! if (defined $offset and $offset =~ s#^([-+])(\d\d):?(\d\d)$##) {
return ($1 eq '+' ?
3600 * $2 + 60 * $3
: -3600 * $2 + -60 * $3 );
--- 391,397 ----
{
my($offset) = @_;
! if (defined $offset and $offset =~ s#^([-+])(\d\d)(\d\d)$##) {
return ($1 eq '+' ?
3600 * $2 + 60 * $3
: -3600 * $2 + -60 * $3 );
***************
*** 407,413 ****
my $o;
if ($$tr =~ s#^
! ([-+]\d\d:?\d\d)
\s+
\(
"?
--- 407,413 ----
my $o;
if ($$tr =~ s#^
! ([-+]\d\d\d\d)
\s+
\(
"?
***************
*** 439,445 ****
$$tzo = &mkoff($o);
printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug;
return 1;
! } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d:?\d\d)(\s+|$)##x) {
$o = $1;
$$tzo = &mkoff($o);
printf "matched at %d.\n", __LINE__ if $debug;
--- 439,445 ----
$$tzo = &mkoff($o);
printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug;
return 1;
! } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d\d\d)(\s+|$)##x) {
$o = $1;
$$tzo = &mkoff($o);
printf "matched at %d.\n", __LINE__ if $debug;
***************
*** 458,464 ****
$$tr =~ s#^\s+##;
! if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|T|$)##) {
# yyyy/mm/dd
($$yr, $$mr, $$dr) = ($1, $3, $4);
--- 458,464 ----
$$tr =~ s#^\s+##;
! if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|$)##) {
# yyyy/mm/dd
($$yr, $$mr, $$dr) = ($1, $3, $4);
***************
*** 682,689 ****
(\d\d) (?# $7)
(
(?# don't barf on database sub-second timings)
! [:.,]
! \d+
)? (?# $8)
)?
)
--- 682,689 ----
(\d\d) (?# $7)
(
(?# don't barf on database sub-second timings)
! (?:\:|\.)
! \d{1,6}
)? (?# $8)
)?
)
***************
*** 748,756 ****
$$tr =~ s/^\s+//;
return 0 if $options{NO_RELATIVE};
-
- # remove the ':' allowed by ISO 8601 standard
- if ($$tr =~ s#^([-+]?\s*\d\d):?(\d\d)#$1$2#) { }
if ($$tr =~ s#^(?xi)
([-+]?)
--- 748,753 ----