NetBSD-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, 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
#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.

Also see <> for useful links,
including pointers to some proposals to fix this bug in a future version
of the C standard.

--apb (Alan Barrett)

Home | Main Index | Thread Index | Old Index