- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If we are dealing with times of events in the present or past then these issues go away, since we presumably know what rules are in effect now, and we hope that no government will retroactively change daylight savings time transitions in the past (just think of the potential for litigation...). History is littered with redefinitions of civil time by fiat, but problems arising from interpretations of old timestamps can be solved by having a sufficiently complete table of all the transitions.
So the trick is to store future event timestamps as localtime plus some representation of the time zone. We need the time zone's legal designation, not just a numeric offset from GMT--the whole point of changing DST rules is that the offset changes, so we need to know who changed the rules, which means we need to know the originating government's identity. Heaven help us if a time zone ever splits into two distinct areas and we have to figure out which of our data came from which area...
Intermediate time values and comparisons can still be done in UT (not UTC - UTC handles leap seconds, but most date/time code in computers doesn't), since the conversion rules between local time and UT presumably will not change during a transaction, so whatever the rules are the computations will be consistent except during the actual hours of transition (as long as the times only have to be accurate within a second per year relative to the current time). Fortunately there are few such hours and they tend to occur at times of day when people aren't scheduling appointments, so this is often not a problem. Any time zone can be used as a reference timezone provided that the time zone does not observe DST (several don't) or have any other nonsequential quirks in its assignment of seconds to hours.
I'm not sure what happens to appointments that were scheduled for the second 01:30 AM local time on October 15th in the affected time zones, since that time of day has simply ceased to exist in those time zones.
Time deltas between times before-and-during or during-and-after the two transition dates will be changed as well. Is an appointment that was originally two hours long and starts at 12:30 AM local time on October 1 now three hours long, or is it still two hours long but starts at 12:30 AM and ends at 1:30 AM?
Suppose a lab schedules a job on a machine that will take exactly 25 hours starting at 09:00 AM local time on October 14th, and is due at 09:00 AM local time on the 15th? The lab commits to these start and delivery times (as local times in the local time zone) prior to the new time zone legislation taking effect. That job will now be finished late, as there are now only 24 hours between those two times, one less than there were at the time when the job was scheduled.
If DST was sensible then a second would take 999.77168949771689497ms for the first six months of the year and 1000.22831050228310502ms for the second (except in leap years when it would be 999.77231329690346083ms and 1000.22768670309653916ms respectively). Most consumer clocks aren't that accurate anyway, so most people will still have to reset their clocks every few weeks to keep the right time even if their clocks did have a "DST" switch to adjust the running speed. Highly accurate clocks (e.g. those accurate enough to care that there have been ~22 seconds added to UTC between 1970 and today) already have to cope with all the time zone insanity (leap seconds, time zones, one-time historic corrections, perturbations in Earth's orbit around the Sun) and wouldn't blink at reporting time in seconds of varying lengths.
Admin
I think it was a winner, or at least a nominee, for the Ignobel prize ("results that shouldn't be reproduced" - not to be confused with a similar journal of "irreproducible results"). It was a real paper and the authors were quite serious about their research as I recall.
Admin
Admin
For anyone else who can't be bothered with hunting it down: https://thedailywtf.com/Comments/The_Abstract_Candidate.aspx?pg=2#87948 http://forums.thedailywtf.com/forums/thread/101043.aspx#101043 http://forums.thedailywtf.com/forums/thread/89063.aspx#89063 https://thedailywtf.com/Comments/Apply_Yourself__0x2e__0x2e__0x2e__at_WTFU.aspx#87097 http://thedailywtf.com/Comments/Virtudyne_0x3a__The_Digital_Donkey.aspx#96055
Or a direct link to the paper: http://www.apa.org/journals/features/psp7761121.pdf
HTH. [image]
Admin
If you want to display times on the local system, you should store your times on the server in UTC. The convert the times locally.
But if you don't do that, and you store the times in the zone they were entered from, then you need to know the local time of the viewer, the local time of the creator, and the time. The is you need to know what time zone the time is stored in. You don't care what timezone the SQL server is in.
The time zone of the SQL server is completely irrevelent.
Take your example. The user in Tokyo creates a transaction that includes a date (I guess it sort of depends on who created the date value?) The guy in NY queries the database... But lets suppose, after the Tokyo dude created the transaction, but before the NY gal queueried it, the server itsel is moved to Paris? Now what do you do?
Hint: don't store local time values, at least not without also storing a known time zone.
Admin
While I agree with most of what you said, you do realize that UTC is just a time. It can still be formated in a variety of ways. You can represent UTC as a string for example. And you can have UTC times BEFORE 1970 and AFTER 2038. you might not have a time_t representation of UTC before 1970 or after 2038, but that has nothing to do with UTC itself.
Admin
Not if you are the CEO. Then everyone else can reschedule around you.
Appointments should be specified and stored with a timezone. When the computer does any calculations, convert to UTC first.
If the Japanese client knows that the appointment is 10am CST and CST is monkeyed with then the Japanese client knows that the appointment has moved. It the appointment is stored with the Japanese timezone then the American participants have to adjust. No problem
The issue, as ever, is to analyze and use what is appropriate to the job and not come out with high-handed pronouncements about what is correct.
Rich
Admin
seriously, if you need this explained, go do computing 101
Admin
Now THERE's a good reason to get rid of C if I ever did see one!
CAPTCHA: howdy. Heck, how did ya'll know that I recently spent time in Dallas?
Bo