Sunday, May 2, 2010

Save the Daylight Saving Time (DST)

Getting home after work can be a different experience in the spring versus in the fall. As now the sun still overlooks the horizon at 6pm, I cannot help trimming my garden, while the dinner is being fixed. When the Daylight Saving Time (DST) just goes into its annual hibernation, driving home in the gloominess has the word "overwork" written all over my body.

Many funny things happen during the on/off switch of the DST. Do you know trains all stopped at 2am for an hour in the spring, but tries to run crazy in the fall because it is suddenly 1 hour behind schedule [1]. We can laugh about this somewhat silly solution to the train problem, but we ought to get serious about how to guard our savings in the bank during the switch of DST.

Say you withdraw $100 at 1:30am; the clock is set back to 1am in 30min; you then withdraw another $100 at the second 1:30am. Can you walk into the bank in the morning and claim you really only did one withdraw and ask for another $100 back into your checking account? If an ATM associates the two transactions with the same text string “Mar 14, 2001, 1:30am”, the bank indeed will have a hard time proving the duplicate withdrawn are not their mistake. We all know there is no free lunch, so how this works?

Computes all use UNIX time [2], i.e., time is not memorized as a text string, but rather as a number. The first “Mar 14, 2001, 1:30am” is recorded as the number 1268530200, i.e., the number of seconds between that precise moment and Jan 1, 1970, 12:00am; the second “Mar 14, 2001, 1:30am” is recorded as 1268533800 (3600 larger than the first one). The banking system has no trouble telling these two transactions apart; software only relies on the UNIX time for all its computing logic, and only use the text format for sole display purpose.

So programmers need to be aware, if you export those transactions from database into a text file, you will only get their text representations and which might well trigger some serious bugs in your data analysis code.

“Spring forward and fall back” is just a zeroth-order approximate to catch up with the sunrise and sunset schedule. With computers and cell phones totally capable of automatically syncing themselves with the Internet, we are well prepared for a DST that is much less disturbance to our daily routines. Here is my idea: the one-hour shift (a step function) during half a year period can be better modeled with a saw tooth function over a year (see figure), i.e., the clock moves forward only 1/3 minute per day in spring and summer, then moves backward 1/3 minute per day day in fall and winter. With such tiny adjustment, the train will run as it should be and we can drive home with the sun positioned where it should be every day.

P.S. If you think a change in a fraction of an hour is hard to accept, you may want to check out the current time in India (http://www.worldtimeserver.com/current_time_in_IN.aspx). It caught me in surprise two weeks ago that the time difference between India and us are 12 hours and 30 minutes!

[1] http://www.webexhibits.org/daylightsaving/k.html
[2] http://en.wikipedia.org/wiki/Unix_time