logoalt Hacker News

dexterdogyesterday at 5:40 PM1 replyview on HN

The integer is a UTC time so it can be sorted. If you need the time zone you store than in a smaller field.


Replies

everforwardtoday at 1:35 AM

This has edge cases that are infrequent but messy because it depends presumes timezone changes are transitive across time and they often aren’t.

Eg I save a date 18 months in the future in US Western time at 0600. 3 months from now the US gets rid of Daylight Savings. You saved it as 1400 UTC (which was correct), which is now an hour off because the local time zone is different.

Encoding it in local time fixes that, because it delays the TZ conversion until you need it and your times stay correct as long as you update tzdb like once a month.