News for hackers. Stuff that matters.
Re:How to save datetimes for future events by laut on Monday March 23, 2015 @11:51AM (#9251514)
The problem is that the meeting time is defined in terms of the "wall time" in Chile.

So if you store the time in terms of UTC, then you are going to have problems when the relation between UTC and the Santiago/Chile timezone changes.

The computer in the example has the time wrong because it stored the time in UTC.

Re:How to save datetimes for future events by sangnoir on Monday March 23, 2015 @12:26PM (#9251713)
Pegging against "wall time" in Chile causes it's own problems. What if the meeting is with a person in "Europe/Berlin" via Skype and the appointment is in a shared calendar. How would the new Berlin time be calculated for the unfortunate Berliner after the Chilean bureaucrats have had their fun?
Re:How to save datetimes for future events by pimlottc on Monday March 23, 2015 @01:19PM (#9252061)
The Berliners should have the meeting entered in their calendar as 10 AM Chilean time. At any given moment when the meeting time must be evaluated or displayed on their own calendars, it can be converted to European time using the current time zone conversion rules.
Re:How to save datetimes for future events by laut on Monday March 23, 2015 @01:23PM (#9252090)
In the example in the blog post the meeting takes place in Chile, so Berlin time is irrelevant.

But let's say you are arranging a conference call between someone in Chile and someone in Berlin. When you arrange the meeting you have to define when the meeting takes place. So you have to choose a time zone along with a time for when the meeting starts. You could choose UTC, Berlin or Santiago. But you have to choose one.

Re:How to save datetimes for future events by igrekel on Monday March 23, 2015 @12:01PM (#9251571)
If it was done properly, the target date in the future should be based on the UTC offset it will have at that time in the future before being converted to UTC for storage. The error is to convert to UTC based on the current UTC offset instead of the "political" timezone that would take in to account proper daylight saving changes.

There are problems when dealing with timezones and daylight saving changes but the example is just a case where the implementation was too naïve.

Re:How to save datetimes for future events by mark-r on Monday March 23, 2015 @12:18PM (#9251665)
The problem is not naive software, the problem is that you can't predict the future. There will always be dates in the future that will be impacted by some rule change that hasn't been officially enacted yet.
Re:How to save datetimes for future events by laut on Monday March 23, 2015 @12:07PM (#9251599)
Author here. Yes, the error was to save any other time than the local time where the meeting is supposed to take place.

The point of the post was to demonstrate that when storing future events that is supposed to happen in a certain timezone, save the local time (along with timezone) instead of converting to UTC.

Re:How to save datetimes for future events by padobson on Monday March 23, 2015 @12:21PM (#9251678)
Why store the UTC offset too, then? Couldn't you get that with the timezone? Then you've got the wall time for the meeting saved, and if you need to convert it to UTC for some reason, you could do it with the most current rules for the timezone.

If the offset becomes meaningless in the event of a rule change anyway, why save it when the most current rules will help you get the offset?

Re:How to save datetimes for future events by laut on Monday March 23, 2015 @12:42PM (#9251797)
Good question!

It is optional to store the UTC offset. The reason to store the UTC offset is to avoid ambiguity there might be when the timezone rules do not change.

If the timezone rules don't change and you happen to be storing a datetime that is during changing from DST to non-DST, you specify which specific time you are talking about. In autumn, clocks could be set back from 3:00 to 2:00. 2:30 happens twice. When you schedule the time you can ask the user "2:30 summer time or 2:30 winter time"?

So you only use the offset for anything in rare case there is an ambiguity (usually because of going off of DST), otherwise you just ignore it. In most cases even if the rules change like in the Chile example you would ignore it as well and use the offset provided by the timezone database.

Re:How to save datetimes for future events by VBprogrammer on Monday March 23, 2015 @02:40PM (#9252616)
Well, it has it wrong, depending on what you are using it for. If you are putting in a calendar entry for the next predicted Lunar eclipse storing them in anything but UTC is wrong.
Re:How to save datetimes for future events by laut on Monday March 23, 2015 @03:43PM (#9252945)
TAI would be better than UTC for the next Lunar eclipse in case you want to be exact to the second ;)

But yes, if you schedule the meeting in UTC, use UTC. The point is not to convert from non-UTC to UTC.

Re:How to save datetimes for future events by arielby on Monday March 23, 2015 @06:38PM (#9253774)
UTC just provides a labeling for TAI/TT seconds, so a count-of-UTC-seconds timestamp is identical to a count-of-TAI-seconds timestamp (assuming the same epoch). Both are different from a count-of-non-leap-UTC-seconds aka POSIX time.
Re:How to save datetimes for future events by laut on Sunday March 29, 2015 @09:30PM (#9287221)
You cannot know for sure how many leap seconds there will be in for instance the next 5 years. So you cannot know for sure exactly how many seconds there will elapse from now until for instance July 1st 2020 midnight UTC.
Re:How to save datetimes for future events by taejo on Tuesday March 24, 2015 @04:25AM (#9255409)
Yes, but we don't know what that labeling will be in the future.