[time-nuts] Re: UTC - A Cautionary Tale

Bill Hawkins bill at iaxs.net
Sat Jul 16 16:38:28 EDT 2005


Robert Lutwak said,
"It ain't "...a few lines."  Properly dealing with timezones, daylight
savings, and leapseconds can easily run into thousands of lines of code, by
the time you include of of the oddball irregularities around the world.  Not
only does the clockmaker have to implement all of this garbage, he has to
test it all."

Garbage is in the eye of the beholder.

Lessee,

/* Main Time Routine */

/* User must set a Leap Second switch when notified of same. */
/* Use a signed number for the switch if you think it will  */
/* jump ahead one second. */

/* Handle one second interrupt */
UTC += 1;

/* Handle Local Time from user-entered parameters, just like MS does */
Local Time = UTC + Local Time Offset;

/* Handle leap second in UTC and local. Clock doesn't do 60 */
If Leap Second switch is set {
   If (UTC is 30 Jun 23:59:59 || UTC is 31 Dec 23:59:59) {
      Subtract leap second from UTC;
      Subtract Leap second from Local Time;
      Turn off leap second switch;
   }
}
/* Handle time shifts from user-entered parameters */
If Local Time matches Spring Ahead {
   Local Time += Spring Ahead Increment;
   Add one year to Spring Ahead;
}
If Local Time matches Fall Back {
   Local Time -= Spring Ahead Increment;
   Add one year to Fall Back;
   }

/* End main time routine */

Sure, there's work to do to convert seconds to clock display format,
but that has been done many times. Is it not part of a CS course?

Yes, the Arabians have 15 minute increments for local time jumps.
I don't see thousands of lines of code to do that.

Back in the sixties, a study was done at Stanford on the effects of
listening to music while programming. Two groups were formed by their
preference for music or not. Then two groups were formed with half
of each preference group. Both groups were given a straight-forward
specification and told to write code for it. One group got music,
the other got silence.

The trick was that the specification twisted the data this way and that
but ended up with the same values as it started. The people who got the
music coded correctly, but most didn't see the short cut. Most of the
silent group did see the short cut. I now believe that MS forces its
programmers to listen to music, because they don't seem to have any
insights.

Goodness, what a waste of time this argument is.

Bill Hawkins






More information about the time-nuts mailing list