in reply to Re^2: High-speed Date Formatting
in thread *SOLVED* High-speed Date Formatting
No timezones; This much is trivial to fix....
Indeed, that is sufficiently efficient to make it silly not to include it. Thank you.
Though It seems silly not to let the regex do its work. I reformulated that as:
sub str2epoch { my( $d, $m, $y, $H, $M, $S, $tzs, $tzh, $tzm ) = $_[0] =~ m[^.... (\d\d) (...) (\d\d\d\d) (\d\d):(\d\d):(\d\d) ([+-])(\d +\d)(\d\d)] or die "Bad format $_[0]"; my $leaps = int( ($y - 1970) / 4 + 0.5 ); (((($y-1970)*365 +$leaps+MONTHS->{$m}+($d-1))*24 +$H)*60 +$M)*60 + +$S - ($tzs eq '-' ? -1 : 1)*$tzh*3600 + $tzm*60; }
See my answer for timegm, which does slow things down, but is a bit more robust
All the others can be handled, but eventually you just end up with the morass that is DateTime which I have no time for :)
(There is a simple workaround for the 2100 problem, but it wouldn't come to mind as I write that. And the last version I wrote is archived on a CD somewhere.)
|
|---|