[Discuss] Interesting linux date bug
DR
vlug at drsol.com
Tue Mar 4 11:42:43 PST 2008
pw wrote:
> DR wrote:
>> pw wrote:
>>> Alan W. Irwin wrote:
>>>> On 2008-03-03 11:34-0800 pw wrote:
>>>>
>>>>> Apparently this second didn't exist:
>>>>>
>>>>> date -u -d "12/31/1969 23:59:59" +%s
>>>>
>>>> What distro are you using? That command works fine on my (64-bit)
>>>> Debian
>>>> testing system:
>>>>
>>>> irwin at raven> date -u -d "12/31/1969 23:59:59" +%s
>>>> -1
>>>>
>>>> Also, the epoch for one second later also works....
>>>>
>>>> irwin at raven> date -u -d "01/01/1970 00:00:00" +%s
>>>> 0
>>>>
>>>> Just to throw a curve ball into the discussion, watch out for leap
>>>> seconds,
>>>> see http://en.wikipedia.org/wiki/Unix_time. The above epochs did
>>>> not have
>>>> leap seconds, but apparently there are Unix computer-time
>>>> inconsistencies at
>>>> epochs where leap seconds (necessary to account for the varying
>>>> rotation
>>>> rate of the earth) occur.
>>>>
>>>> Alan
>>>
>>> I'm using centos on that machine. Centos is a peared down
>>> redhat style distro.
>>>
>>> The seconds on either side of that work fine. The actual +%s
>>> value of that second should be -1 (negative one), just as you show.
>>> On that machine the date comes up as invalid.
>>>
>>> This is not really a big deal for me. I only noticed this because
>>> I was making a table of unix seconds values for the ends of years.
>>>
>>> ie:
>>>
>>> for YEAR in `seq 1900 2035`; do date -u -d "01/01/$YEAR 23:59:59"
>>> +%s; done
>>>
>>> Does the linux date have a leap seconds flag/setting.
>>> Maybe that's the problem.
>>>
>>> Peter
>>
>> I am using:
>>
>> Centos Version 5
>> date (GNU coreutils) 5.97
>>
>> and I get the following results:
>>
>> $ date -u -d "12/31/1969 23:59:58" +%s
>> -2
>> $ date -u -d "12/31/1969 23:59:59" +%s
>> -1
>> $ date -u -d "01/01/1970 00:00:00" +%s
>> 0
>> $ date -u -d "01/01/1970 00:00:01" +%s
>> 1
>>
>> Deid
>
> My version of Centos.
>
> Linux version 2.6.9-42.ELsmp (buildcentos at build-i386) (gcc version 3.4.6
> 20060404 (Red Hat 3.4.6-3)) #1 SMP Sat Aug 12 09:39:11 CDT 2006
>
> Running on dual Xeons and a gig of memory.
Linux giga 2.6.18-53.1.4.el5xen #1 SMP Fri Nov 30 01:53:35 EST 2007 i686
athlon i386 GNU/Linux
AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
1 gig of memory.
]$ for YEAR in `seq 1968 1970`; do date -u -d "12/31/$YEAR 23:59:59"
+%s; done
Gives:
-31536001
-1
31535999
Mmmmm?
Deid
More information about the Discuss
mailing list