Linux "date" command ignores leap-seconds?

Bob Jonkman bjonkman-w5ExpX8uLjYAvxtiuMwx3w at public.gmane.org
Tue Jan 15 03:08:13 UTC 2013


On 13-01-14 06:10 PM, Bill Duncan wrote:
> The whole point I believe, is to insert them in there *without* accounting
> for it. 

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.

--Bob.

Bob Jonkman <bjonkman-w5ExpX8uLjYAvxtiuMwx3w at public.gmane.org>         http://sobac.com/sobac/
SOBAC Microcomputer Services              Phone: +1-519-669-0388
6 James Street, Elmira ON Canada  N3B 1L5  Cell: +1-519-635-9413
Software   ---   Office & Business Automation   ---   Consulting 


On 13-01-14 06:10 PM, Bill Duncan wrote:
> The whole point I believe, is to insert them in there *without* accounting
> for it.  If you think about it, if the userland programs added the seconds
> in there, then you wouldn't have accomplished anything.  eg.  43years + N
> seconds would still be just that..  43 years + N seconds.
>
> The leap seconds are "inserterted" while clocks are effectively standing
> still for an extra second, so date and their userland ilk will not know
> about it..
>
> Cheers.
>
> [William Porquet said:]
>> IIRC, leap-seconds are added as needed by an independent origanization
>> to account for the slight lag of the earth's rotation around the sun.
>>
>> http://en.wikipedia.org/wiki/Leap-second#Insertion_of_leap_seconds
>>
>> Cheers,
>> W.
>>
>> On 14 January 2013 17:23, Lennart Sorensen <lsorense-1wCw9BSqJbv44Nm34jS7G+G/Ez6ZCGd0 at public.gmane.orgca> w=
>> rote:
>>> On Mon, Jan 14, 2013 at 05:19:15PM -0500, Walter Dnes wrote:
>>>>   I'm not complaining, because I prefer it that way, but I just want to
>>>> check.  First, let's get the number of seconds between 1970/01/01 and
>>>> 2013/01/01, i.e. exactly 43 years.
>>>>
>>>> [d531][waltdnes][~] date +%s -u -d 2013-01-01
>>>> 1356998400
>>>>
>>>>   Next, divide by 86,400 (number of seconds in a day.
>>>>
>>>> [d531][waltdnes][~] echo $(( 1356998400 / 86400 ))
>>>> 15706
>>>>
>>>>   And confirm that this is an exact division with zero remainder.
>>>>
>>>> [d531][waltdnes][~] echo $(( 15706 * 86400 ))
>>>> 1356998400
>>>>
>>>>   Divide 15706 days by 365
>>>>
>>>> [d531][waltdnes][~] echo $(( 15706 / 365 ))
>>>> 43
>>>>
>>>>   Multiply by 365 to check the remainder
>>>>
>>>> [d531][waltdnes][~] echo $(( 43 * 365 ))
>>>> 15695
>>>>
>>>>   15706 - 15695 =3D 11.  This is due to 11 intervening leap years, i.e.
>>>> 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, and 2012.
>>>>
>>>>   So it all works out.  Is this supposed to continue, or are there any
>>>> plans to include leap seconds?  Right now, I'd prefer not to.
>>> I do not believe information on leap seconds is part of the timezone data=
>> ,
>>> so there is nowhere to get this information from as far as I know.
>>>
>>> I think leap seconds are just to keep midnight at midnight and the
>>> historical effect of them is so small as to be generally irrelevant and
>>> is hence ignored.
>>>
>>> --
>>> Len Sorensen
>>> --
>>> 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
>>
>>
>> --=20
>> William Porquet, M.A. =E2=98=A8 mailto:william-HPpJ5Ac2/Hg at public.gmane.org =E2=98=A8 http://ww=
>> w.2038.org/
>> =E2=80=9CLuck is what happens when preparation meets opportunity.=E2=80=9D =
>> - Lucius
>> Ann=C3=A6us Seneca
>> --
>> 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
>>
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://gtalug.org/pipermail/legacy/attachments/20130114/0ec68e9e/attachment.sig>


More information about the Legacy mailing list