Subject: | Cannot parse an IS0 8601 date and time |
An ISO 8601 date and time, as recommended by the W3C
(http://www.w3.org/TR/NOTE-datetime), is represented as
"YYYY-MM-DDThh:mm:ssTZD", with a "T" separating the date and the time
part, but the Class::Date::new() method expects a blank instead.
The attached patch makes the new() method accept either a blank (as in
version 1.1.9) or a "T".
This change allows me to parse an ISO date (without timezone) simply by
Class::Date->new(ISO_DATE).
Parsing also the timezone is probably easy, but I do not need it in this
particular project.
Best regards,
Paulo Custodio
Subject: | Class-Date-1.1.9.patch |
*** Class/Date.pm.ori Sun May 14 21:34:29 2006
--- Class/Date.pm Mon Jun 5 20:07:09 2006
***************
*** 228,234 ****
$obj->_recalc_from_epoch;
return $obj;
} elsif ($time =~ m{ ^\s* ( \d{0,4} ) - ( \d\d? ) - ( \d\d? )
! ( \s+ ( \d\d? ) : ( \d\d? ) ( : ( \d\d? ) (\.\d+)?)? )? }x) {
my ($y,$m,$d,$hh,$mm,$ss)=($1,$2,$3,$5,$6,$8);
# ISO(-like) date
return $s->new_from_array([$y,$m,$d,$hh,$mm,$ss],$tz);
--- 228,234 ----
$obj->_recalc_from_epoch;
return $obj;
} elsif ($time =~ m{ ^\s* ( \d{0,4} ) - ( \d\d? ) - ( \d\d? )
! ( [\s|T]+ ( \d\d? ) : ( \d\d? ) ( : ( \d\d? ) (\.\d+)?)? )? }x) {
my ($y,$m,$d,$hh,$mm,$ss)=($1,$2,$3,$5,$6,$8);
# ISO(-like) date
return $s->new_from_array([$y,$m,$d,$hh,$mm,$ss],$tz);