Linux "date" command ignores leap-seconds?

Eric B gyre-Ja3L+HSX0kI at public.gmane.org
Thu Jan 17 16:58:39 UTC 2013


On Wed, 16 Jan 2013, David Collier-Brown wrote:

> On 01/16/2013 01:36 AM, Eric B wrote:
> > On Tue, 15 Jan 2013, Lennart Sorensen wrote:
> >
> >> On Mon, Jan 14, 2013 at 10:08:13PM -0500, Bob Jonkman wrote:
> >>> Depends on what you're doing.  Yes, the wall clock needs to stand still
> >>> for a second to keep up with Earth's rotation, but the timer that tells
> >>> me how long a process is running needs to keep running during a leap
> >>> second.  If I ask how much time has elapsed since 1 January 1970 the
> >>> 'date' command appears to give the wrong answer by not counting the leap
> >>> seconds.
> >>>
> >>> Does it matter? Depends on what you're doing, and how accurate you need
> >>> to be.
> >> Well as far as I know the decision has been that unix timstamps do
> >> not account for leap seconds.  So if you happen to care, you can't use
> >> unix timestamps without additional information and adjusting.  Most things
> >> don't care, so keeping unix timestamps simple makes sense.
> > Yes, unix timestamps do not account for leap seconds, BUT
> > that is inconsistent with the 'man date' documentation.
> >
> >   $ man date
> >     ...
> >     %s  seconds since 1970-01-01 00:00:00 UTC
> >
> > UTC has a specific scientific meaning which includes leap
> > seconds.  UTC is not linear.
> > Therefore the difference between two UTC timestamps must
> > include leap seconds.
> >
> > If you ask how many seconds have elapsed since 1 January 1970 UTC,
> > the unix 'date' command gives the wrong answer.
> >
> > Simple solution:  fix the man page.
> > ie:
> >   %s  seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds
> >
> > --
> > Eric B.
> > --
> > The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> > TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> > How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
> >
> My leaky memory says Solaris and at least HP/UX *include* leap seconds.

Solaris 'date' (SunOS 5.9) doesn't support '%s'.
Where did you come across leap seconds?

>  Posix should say (but only uses the "UTC" wording). Wikipedia describes
> the behaviour as excluding leap-seconds, with more discussion in the
> "talk" page, and discusses Unix adjusting the "epoch" to get the
> leap-seconds right in %s...

Adjusting the epoch seems ugly; it should be a fixed point in
time.

--
Eric B.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list