pico-engine icon indicating copy to clipboard operation
pico-engine copied to clipboard

Time zones have crept into our `time:` library

Open b1conrad opened this issue 3 years ago • 2 comments

I noticed this when studying cookies. Therein expiration dates are noted in RFC 822 format, rather than the ISO 8601 format which we have been using.

At the time of this writing, that is "Thu, 11 Mar 2021 23:09:40 GMT" in RFC 822 and "2021-03-11T23:09:40.334Z" in ISO 8601, and just after 4 p.m. at the place of this writing, things have gone wrong.

To convert the latter (given by time:now()) into the former, the format needed for a cookie, I used this code

time:now().time:strftime("%a, %d %b %Y %T GMT")

and got, unexpectedly "Thu, 11 Mar 2021 16:09:40 GMT" because time:strftime() doesn't just format the passed in string, but shifts it into the timezone of the machine running the pico engine.

The bug is that I don't know how to display a date/time that I have in hand in ISO 8601 format in RFC 822 format.

The enhancement is that I would like to be able to handle this kind of thing. Time zones would be nice too, if we could figure out a way to do it cleanly.

The question is, what should we do about this?

Quoting from "Date math is hard, let's do it tomorrow, A Date has no time zone information."

b1conrad avatar Mar 11 '21 23:03 b1conrad