7 ms·
While I understand the point about displaying a time in a given timezone (output/strftime) I don't see how specifying a timezone on a epoch count makes any sen
by pheasantquiff 4y ago
While I understand the point about displaying a time in a given timezone (output/strftime)
I don't see how specifying a timezone on a epoch count makes any sense (input/strptime).
A 'number of seconds since epoch' (%s) is a _duration_, not a time. It makes no sense to attach a time zone to it. (This seems to have been the initial response from the project maintainer).
From the original article the reported "bug" is about _parsing_ an epoch duration, not about displaying a time.
DateTime.strptime('0 +0100', '%s %z')
Probably I am missing something but I've re-read the original article and I cannot see this point addressed directly (examples are given but they have to do with displaying/output, not parsing).
- felipec 4y agoYou can argue that attaching a time zone to a `%s` doesn't make sense, but a lot of people do it, and more importantly: it doesn't hurt. If you do `Time.strptime('0 +0100', '%s %z').to_i` you get the correct result: "0". That is: the number of seconds since the epoch is correctly parsed. The time zone is extra information that doesn't affect `%s` in any way. In other words: it's orthogonal.