Hacker News new | past | comments | ask | show | jobs | submit login

Postgres have done a really good job here. It not only understands offsets (which most devs think are timezones) it also understands timezones. What's the difference?

GMT-8 is an offset. America/New_York is a timezone.

This becomes important when you want to schedule a meeting on the east coast of the USA in April - Europe and the US change DST on different dates. But if you tell postgres you want a time in a particular zone it will do the calculation correctly. If you use an offset you might turn up an hour late.




What's the point of unqualified offsets like that anyway? You either use UTC or a local time in the appropriate tz.


They are useful for when you want the semantics of UTC but still a human readable time. One example is logs that people will actually read. People have a hard time doing mental math but 14:00-05:00 is just as valid as 19:00+00:00 and easier for people in Eastern Time.

It's also useful for disambiguating a local time:

2018-11-04T01:45-05:00 America/New_York 2018-11-04T01:45-04:00 America/New_York

That said, I do think they are mostly around for less noble reasons: they are way easier to serialize than actual time zone rules.


Useful when you need to store the offset of a specific event in the past where the timezone data doesn't matter. Especially logs since you want to know when it occured, so you store unqualified offset so the DoS attack doesn't suddenly happen an hour earlier than it says in the logs if DST happens between attack and the admin reading the log.


How do you update the tzdb?


It looks like it's embedded in the PostgreSQL source, tho I imagine there's probably also a way to update it without upgrading PostgreSQL itself:

- [postgres/src/timezone at master · postgres/postgres](https://github.com/postgres/postgres/tree/master/src/timezon...)


[postgresql - How to import tz data (IANA) into Postgres server - Stack Overflow](https://stackoverflow.com/questions/26560003/how-to-import-t...)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: