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

Mike S mikes at flatsurface.com
Sat Jul 16 18:44:05 EDT 2005

At 06:12 PM 7/16/2005, Bill Hawkins wrote...
>Um, would you care to point out the more serious bugs?

The UTC time sequence with your code would go (at the 1 second interrupts):


Leading to ambiguous (duplicated) timestamps. The correct solution is closer to:

   Disable interrupts;
   If (UTC is [last day of any month] 23:59:59 || leap second is negative) {
      UTC = [next day] 00:00:00;
      Clear leap second }
   If (UTC is 1 [any month] 00:00:00) || leap second is positive) {
      UTC = [prior day] 23:59:60;
      Clear leap second }

Which of course requires applications and the clock itself to be able to handle 23:59:60 (which is a legitimate time in UTC). Routines which calculate time intervals also require that a table be kept of when leap seconds occur, so they can be accounted for.

More information about the time-nuts mailing list