Always store the authoritative version of a time, which usually is UTC for points in time, but local time for calendar based things.
The duplicate/missing hour around DST switching can also be quite annoying.
Always store the authoritative version of a time, which usually is UTC for points in time, but local time for calendar based things.
The duplicate/missing hour around DST switching can also be quite annoying.
For anything interacting with planning though, the user's needs should be considered. Often what you actually want to store is a "recurrence rule" for a single event, while being sure to include the defining aspects picked, or at least confirmed, by the user.
>What time is it?
2am.
>It’s been 2am for 2 hours!
That shouldn't be a problem for datetimes in the past. tzdata contains not only the current offset but all historical ones as well.
It might be a problem for /future/ datetimes. If I say the meeting is at 1700 America/New_York and the local civil authority changes the offset in the meantime I probably don't want the meeting to move in local time.
I filed a bug (JDK-8214243) but basically it's a known issue and there's no fix.
Oh yes. I used to work for company which produced medical software which continuously recorded patient data. Those duplicated or missing hours were always the worst and error-prone use cases.
Don't know if they've fixed it but when I had a Fitbit, they never was able to get these DST change over events handled correctly. What's worse is that their website and their app both handled the change over in different ways, both wrong.
1 AM, 2 AM (CET), 2 AM (CEST), 3 AM, 4 AM...
or
1 AM, 2 AM (CEST), 4 AM (CET), 5 AM, ...
If a night loses 1 hour, the train stops for less time at the scheduled stops, or arrives with a delay. If the night gains an hour, the train waits somewhere for an hour. Which sounds like a painful thing, having to travel (or wait) an extra hour because of clocks.
Interestingly if the night loses an hour, the trains are automatically an hour behind schedule...
Then there's the possibility of timezones straight moving around which can make entire days replay or disappear e.g. in Samoa there is no 2011-12-30, the day literally doesn't exist, Samoa local calendar goes straight 2011-12-29 to 2011-12-31, because at midnight the country switched from UTC-11:00 to UTC+13:00.