Subject: | Time::ParseDate subseconds limited to 6 digits |
Perl Version: v5.10.1
OS: ubuntu 11.04
Module Version: packaged in ubuntu as libtime-modules-perl 2006.0814-2
Module: Time::ParseDate
Module: Time::JulianDay
Author: David Muir Sharnoff
Time::ParseDate parses subseconds as documented, but it only parses up to six digits of them: \d{1,6}. if i set
the option "WHOLE", which i want, it won't parse timestamps as reported by ls running in full-iso timestamp
format (ls --time-style=full-iso). the subsecond values are greater than 6 digits. i would like to use it with
this output. timestamps from the above ls command look like this: "2010-09-22 09:55:06.026336444". subsecond
digits are greater than six and thus fail to parse.
i made a quick changes to parse unlimited subseconds:
\d{1,6} -> \d+
it parses now, but the string returned has only 6 subseconds still. the relevant debug output is:
jd_secondsgm(2456190, 10, 19, 43.3677537123412) = 1348049983.36775
which seems to be the doing of Time::JulianDay. I have not figured that piece out yet. i attached a simple test
script to run. The parsedate patch isn't really needed, but i added a half-assed one here anyway. it's not a
complete fix because something has to happen in Time::JulianDate as well.
Subject: | Time::ParseDate.patch |
*** /usr/share/perl5/Time/ParseDate.pm 2008-05-06 05:44:53.000000000 +1200
--- /tmp/Time/ParseDate.pm 2012-09-19 11:21:07.911144123 +1200
***************
*** 690,696 ****
(
(?# don't barf on database sub-second timings)
[:.,]
! \d{1,6}
)? (?# $8)
)?
)
--- 690,696 ----
(
(?# don't barf on database sub-second timings)
[:.,]
! \d+
)? (?# $8)
)?
)
Subject: | error.pl |
use strict;
use warnings;
use Time::ParseDate;
my $seconds = parsedate("2012-09-19 09:50:59.344702843", WHOLE => 1, SUBSECOND => 1);
if (! $seconds)
{
print "Parse Failure\n";
exit 1;
}
print "Parse Success!\n";