News for hackers. Stuff that matters.
Re:How to save datetimes for future events by bickfordb on Monday March 23, 2015 @11:44AM (#9251475)
Don't most time zone databases store the date of rule changes? http://en.wikipedia.org/wiki/Tz_database#File_formats
Re:How to save datetimes for future events by laut on Monday March 23, 2015 @12:11PM (#9251631)
Yes. But in this case the timeline is something like this:

1) You arrange a meeting 2) Then, after you have arranged the meeting, politicians/bureaucrats decide to change the time zone rules 3) Your meeting takes place

At 1) the rules are different from at 2). At 1) you cannot see into the future and anticipate how the rules will be at 2), because you don't have a time machine. So you have to be ready for it by implementing in a way that is resistant to timezone rule changes. For instance like the described solution.

Re:How to save datetimes for future events by sangnoir on Monday March 23, 2015 @12:19PM (#9251672)
The prescribed solution does not solve for all use cases though.

Imagine if the meeting included a conference call to someone in Australia. A day before the meeting, the bureaucrats change the DST rule. The meeting invite for the Australian now has incorrect time. Storing as local time will work against events applicable across timezones.

The problem isn't with UTC, it is unexpected rule changes that the converting agent (software) did not predict. That logic will have to be coded in.

Re:How to save datetimes for future events by philh on Monday March 23, 2015 @12:43PM (#9251811)
Yeah, it seems like there's no general solution to this. If I put in '10AM in Chile' for grabbing coffee with a friend, I probably want it to stay in wall time no matter what happens to the offset.

If I'm making a note of a solar eclipse, I need it to stick with physical time, and if the offset changes the reported time changes.

If I'm scheduling a conference call to Australia, then when the offset changes, one of us is going to have to reschedule, and my calendar can't know which. (We might both have to reschedule, if neither of us can move it by a single hour.)

It might be able to say "you scheduled this at 10AM, but the DST rules changed, and that physical time is now 11AM wall time, what to do?" My Australian colleague isn't going to get that warning, unless her calendar knows that she's talking to someone in Chile, but as long as one of us knows about the problem, we should be okay. But I'm not sure I trust this to cover all bases.

Re:How to save datetimes for future events by laut on Monday March 23, 2015 @12:33PM (#9251745)
Let's say the meeting is supposed to take place at 15:00 "wall time" in Sydney on March 30th. Someone changes the DST rules. The meeting still takes place at the specified time. Remember we specify the time at Australia. So far so good.

Usually the time from a new update is released at least a week before the change takes place. So your software might alert you about the time on the same day or the day before of the meeting. Or even half an hour before. Do the calculations at that time of the alert with the newest timezone data. And if the software is up to date with timezone database changes, users in other time zones will be alerted about the correct time. The calculation will be made before the meeting from 15:00 Sydney to whatever other time zone someone might be in.

Re:How to save datetimes for future events by mark-r on Monday March 23, 2015 @12:27PM (#9251719)
Why would the time for the Australian be incorrect? If the meeting organizer is in Chile, then the meeting time would be ruled by Chile's local clock. If the rule change affects the difference between Australia and Chile, then simply loading the updated rules on both sides should readjust things automatically - if the time was stored as Chile local, not UTC.
Re:How to save datetimes for future events by dragonwriter on Monday March 23, 2015 @12:40PM (#9251781)
The fact that the meeting organizer in Chile does not imply that the key constraint for the meeting time was in Chile, rather than in the schedule of the Australian attendees.

(Of course, its actually possible that there were essential constraints on both sides, in which case, the problem is more difficult, or that the key constraint was that the call needed to immediately precede or follow an event in a timezone different from Australia or Chile.)

Really, determining the key intent here is hard, and there is no one rule that makes it painless in all cases. There are lots of different possible intents with timing, and there is no single general rule that handles all possible changes in local time rules between the time an event is scheduled and the time it occurs.

Re:How to save datetimes for future events by laut on Tuesday March 24, 2015 @11:52AM (#9257373)
If I enter "10:00 in Chile" in a calendar app I expect it to stay "10:00 in Chile". And not magically change to "11:00 in Chile". That is what the example was.
Re:How to save datetimes for future events by mark-r on Monday March 23, 2015 @12:09PM (#9251620)
That doesn't help if you don't save the time zone rules that were in effect when you converted the original timestamp to UTC. The problem is that you've already converted to UTC using the wrong rules, so to make things right you need to unconvert then reconvert again. But there's no way to know which timestamps need correcting and which ones don't.

The databases keep track of the zone changes so you can use the proper rules for conversions in the past. They don't protect you from changes in the future.

Re:How to save datetimes for future events by x1798DE on Monday March 23, 2015 @11:57AM (#9251549)
Yeah, this was always my understanding - time zones, DST participation and dates, etc all change more frequently than you'd expect, and time zone databases keep track of when things happen precisely for this reason. If that weren't happening, I think people would have found that many of their timestamps become obsolete / inaccurate relatively quickly.

That said, it does tie the stability of your datetimestamp to the stability of the tz database. I think that's a pretty good bet, but it's nice to be aware of where your abstractions can leak.

Re:How to save datetimes for future events by stygiansonic on Monday March 23, 2015 @11:58AM (#9251559)
That's what I thought too. Based on the discussion surrounding this example[0], I believe that's the case. Still, date/time is a tricky subject to get right.

0. http://stackoverflow.com/questions/6841333/why-is-subtractin...