You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I can explain this most easily with a demonstration, using faketime (from the package of the same name):
[cibola:~/proj/date-easy] date +%z
-0700
[cibola:~/proj/date-easy] faketime 12/31/1969 date +%z
-0800
[cibola:~/proj/date-easy] perl -MTime::ParseDate -le 'print parsedate("1969/12/31 16:00:00")'
-3600
The proper answer, in my particular timezone, is 0.
This problem appears to be happening because this particular example fires tz_local_offset (in Time::Timezone), which doesn't account for any discrepancy in DST between the past and present. tz_offset, for instance, specifically checks for the $dst flag of the time in question to see if it should account for DST in choosing the right timezone. But tz_local_offset doesn't bother, since there's only a single timezone.
However, even though there's no difference geographically, there's a difference temporally. Currently we're in DST where I am, but the time being parsed was not in DST at that point in time. So the offset being used is actually one hour off.
I don't see a quick fix here, although I note that Date::Parse gets it right, so perhaps they have some code worth stealing. But I think it's just a matter of comparing the DST flag for the passed in time vs the current time and adjusting appropriately if they don't match.
Or perhaps you can see a more elegant solution. :-)
The text was updated successfully, but these errors were encountered:
I think I can explain this most easily with a demonstration, using
faketime
(from the package of the same name):The proper answer, in my particular timezone, is 0.
This problem appears to be happening because this particular example fires
tz_local_offset
(in Time::Timezone), which doesn't account for any discrepancy in DST between the past and present.tz_offset
, for instance, specifically checks for the$dst
flag of the time in question to see if it should account for DST in choosing the right timezone. Buttz_local_offset
doesn't bother, since there's only a single timezone.However, even though there's no difference geographically, there's a difference temporally. Currently we're in DST where I am, but the time being parsed was not in DST at that point in time. So the offset being used is actually one hour off.
I don't see a quick fix here, although I note that
Date::Parse
gets it right, so perhaps they have some code worth stealing. But I think it's just a matter of comparing the DST flag for the passed in time vs the current time and adjusting appropriately if they don't match.Or perhaps you can see a more elegant solution. :-)
The text was updated successfully, but these errors were encountered: