Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: date(1) doesn't handle leap-seconds?



On Sun, 2 Nov 2008, Alan Barrett wrote:

On Sun, 02 Nov 2008, Paul Goyette wrote:
$ TZ=GMT; export TZ
$ echo $(( $(date -ju '+%s' 200601010100) - $(date -ju '+%s' 200512310100) ))
86400
$

Is this a bug?

Yes, but the bug is in POSIX, which specifies that "seconds
since the epoch" (as used by several functions including
time(3)) counts exactly 86400 seconds per day.  See
<http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html
#tag_04_14> for the relevant definition in SUSv3.  This is incompatible
with the natural meaning of "seconds since the epoch", which would count
86400 seconds on most days, but 86399 or 86401 seconds on days with
deleted or inserted leap seconds.

Ah, OK. So POSIX syystems are all currently off by 23 seconds, and soon to be off by 24 seconds (there's another leapsecond coming up at the end of 2008). Bummer.


----------------------------------------------------------------------
|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 |  paul%whooppee.com@localhost   |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette%juniper.net@localhost |
----------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index