3 ms·
One complication with that format is that local time can be ambiguous or not exist at all, if the time is during DST switching.
by CodesInChaos 3y ago
One complication with that format is that local time can be ambiguous or not exist at all, if the time is during DST switching.
- codetrotter 3y agoAdd one extra bit to store “disambiguation”. Value 0 meaning “if there is a DST switch, interpret the time as the chronologically earlier one” Value 1 meaning “if there is a DST switch, interpret the time as the chronologically later one”.
- CodesInChaos 3y agoYes, a suffix like `S`/`W` (for Summer/Winter) or `+`/`-` in place of Z would help with disambiguation. But you still need to handle the case where the local time is skipped. You could pick the timestamp during which the skip happens, but that'd lead to an offset that can contain fractional seconds, which almost no datetime library supports.
- proto_lambda 3y agoThat works until a country decides to hop across the international date line the day after they switch from DST to normal time, and the timestamp occurs three times ;)