Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Past times can be one hour off because of DST mismatch #8

Open
barefootcoder opened this issue Apr 15, 2016 · 2 comments
Open

Past times can be one hour off because of DST mismatch #8

barefootcoder opened this issue Apr 15, 2016 · 2 comments

Comments

@barefootcoder
Copy link

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. :-)

barefootcoder added a commit to barefootcoder/date-easy that referenced this issue Apr 17, 2016
technically, it's only a TODO test if the test is being run during DST
filed an upstream bug report: muir/Time-modules#8
@barefootcoder
Copy link
Author

So, if I were to submit a patch attempting to fix this issue, is that something that you would consider merging?

@muir
Copy link
Owner

muir commented Dec 8, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants