Re:How to Design Better APIs
by mulmboy on Friday March 11, 2022 @08:28PM
(#30648134)
They can include a local timezone. Sometimes there's a big difference between 12am in UTC+0 and 3am in UTC+3 despite representing the same instant in time.
[ Parent
| on HN ]
Re:How to Design Better APIs
by inopinatus on Friday March 11, 2022 @09:03PM
(#30648299)
True enough, but I would still recommend that API responses normalize to UTC (Z suffix) in the general case and document as much, and if actually returning a timestamp with a specific timezone, document the intended meaning.
+1, if your application cares about time then you should just tell your users all dates will be normalized to UTC and they are responsible for displaying them in a preferred time zone.
Time zone rules change relatively frequently - future dates may be better stored in the appropriate time zone, optionally along with the UTC offset at the time of recording, so you don't report incorrect information when the rules do change on you.
Past dates should always be in UTC, for the same reason - timezone rule changes are sometimes even retroactive.