Re:Strict APIs vs. Forgiving APIs
by bartvk on Wednesday October 28, 2020 @03:25PM
(#24923058)
An ISO date with timezone can be useful, if you would like to know the timezone when a particular bit of data was recorded.
[ Parent
| on HN ]
If you mean ISO 8601 and its "2007-04-05T12:30-02:00" timezone thingy, not really.
It doesn't store a timezone, but a UTC offset. Which is a problem because the UTC offset of a timezone may change.
This happens rarely enough that people do indeed use "ISO 8601 + offset" to store "timezoned" timestamps, but often enough that it'll probably end up corrupting your data sooner or later.
Well, usually what you want is actully the UTC offset, not the timezone, because that's what you need to get the actual-wall-clock timestamp of the event. If you all you have is a timzeone, then you need an accurate historical tzdata and also you need to be sure that the system had accurate tzdata itself when it produced the timestamp.
Of course, if you're storing the timestamp of a future, planned event, then yes, you need a timezone. But for historical records, store the UTC offset that was in effect when the event happened.