Subject: | TimeDate parsing lpd log files |
I am using timedate to parse lpd-generated log files. lpd uses a '-' to separate its time and date values. Also, I had a problem with parsing the new millenium two digit years.
This patch takes care of both:
*** TimeDate-1.1301/lib/Date/Parse.pm Thu Jun 6 14:12:58 2002
--- TimeDate-1.1301-ys/lib/Date/Parse.pm Sun Jun 16 12:22:43 2002
***************
*** 88,94 ****
$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 {
--- 88,94 ----
$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 {
***************
*** 184,189 ****
--- 184,190 ----
}
$year -= 1900 if defined $year && $year > 1900;
+ $year += 100 if defined $year && $year < 50;
$zone += 3600 if defined $zone && $dst;
Thanks,
--Yan