by codebeaker · 9y ago · 0 comments
The example (which is not so uncommon) that an appointment is set in timezone X, author of the service storing the appointment helpfully converts to UTC, timezone of the originating country changes and then the "return" from UTC to source timezone is incorrect, because now UTC-0600 is actually UTC-0700.
In short, any conversion that reduces precision is flawed. Dropping timezones after normalizing them to a canonical format makes it impossible to restore the conversion.
Dropping timezones after normalizing them to a canonical
format makes it impossible to restore the conversion.
Except this isn't true.Normalizing TimeZones converts them to ZULU/GMT. You can de-normalize ZULU/GMT to any timezone easily and well within the UTC standard by converting them back to the local timezone. No data is lost, and the standard makes this process transparent.
Actually converting from Zulu to Local should always be done on the client side as their locality settings _should_ include a timezone.
In practice there are edge-cases that you can't account for when the theory meets the practice of the messy, real world.
For example, last year Turkey decided, with a couple of days notice, to delay the daylight savings switch [1]. If you did things in UTC, you would have no idea which of your dates was now wrong, which ones that needed to be fixed.
Storing UTC might be useful in its own right, but if you're looking for correctness, you need to store the details and not discard the extra information.
What time encoding format _can_ deal with changes like this? Are their libraries that update often enough?
Also provided the Host OS had the proper time offset the UTC conversion would work fine, even for cases of fractional-hour timezones. So this can would be covered if the client updated their TZ locality.
A calendar appointment isn't identified by a UTC instant; it's identified by a predicate.
(1) event scheduled for 7:00pm local time in a certain place on a certain date, that needs to be at that local time regardless of whether the government changes to time zone of that locality, or changes DST rules.
(2) event at 7:00pm Central Time ona certain date, that needs to occur at that time in the regardless of DST date changes.
(3) event at 7:00pm CST, which has a fixed offset from UTC.
But it's only a small step farther to allow scheduling an appointment relative to an arbitrary time zone, instead of the one you happen to currently be in. Which naturally includes UTC, for situations where astronomical time is what you really care about.
Of course it can't happen by magic, and you rely on the authors of the timezone libraries (a thankless task in itself), but if you remove a dimension of your data, nobody can ever help you.