lkml.org 
[lkml]   [2009]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug: Status/Summary of slashdot leap-second crash on new years 2008-2009
Alan Cox wrote:
>> UTC equivalent to conversion on the naive basis that leap seconds are ignored and all
>> years divisible by 4 are leap years. This value is not the same as the actual number of
>> seconds between the time and the Epoch, because of leap seconds and because clocks are not
>> required to be synchronized to a standard reference.
>>
>
> I'm not sure what you are quoting from but it is out of date on the
> subject of leap years.
>

The range of signed 32-bit times is 1901 through 2039, which has only
one century, 2000, which is a leap year. So the caveat for leap years
is correct but unnecessary.


So I've discoverd, at least on Ubuntu, something wonderful and
reassuring. It already works exactly the way I think is correct. Look:
I create a test timezone with no daylight saving and one leap second:

davidn@takauji:~/timetest$ cat tz
Zone testzone 0:00 0 XXX/YYY
davidn@takauji:~/timetest$ cat leapseconds
Leap 2008 Dec 31 23:59:59 + S
davidn@takauji:~/timetest$ zic -d . -L leapseconds tz

Then the test program, which makes a time_t (what time() returns) for a
few seconds before the leap second, then counts off seconds...

davidn@takauji:~/timetest$ cat timetest.c
#include <time.h>
#include <stdio.h>

main() {

setenv("TZ", ":/home/davidn/timetest/testzone", 1);

struct tm tm1 = { 55, 59, 23, 31, 11, 108 };
time_t t1 = mktime(&tm1);
int i;
for (i = 10; --i; t1++) printf("ctime(%ld) = %s", t1, ctime(&t1));

return 0;


}


Observe two 23:59:59's. Apparently it could be better if the second
23:59:59 was 23:59:60, but I prefer it this way.

davidn@takauji:~/timetest$ ./timetest
ctime(1230767995) = Wed Dec 31 23:59:55 2008
ctime(1230767996) = Wed Dec 31 23:59:56 2008
ctime(1230767997) = Wed Dec 31 23:59:57 2008
ctime(1230767998) = Wed Dec 31 23:59:58 2008
ctime(1230767999) = Wed Dec 31 23:59:59 2008
ctime(1230768000) = Wed Dec 31 23:59:59 2008
ctime(1230768001) = Thu Jan 1 00:00:00 2009
ctime(1230768002) = Thu Jan 1 00:00:01 2009
ctime(1230768003) = Thu Jan 1 00:00:02 2009


Perhaps this is distribution-dependent, but even so, there's no need for
the kernel to drop the second (and it's wrong if it does.)


\
 
 \ /
  Last update: 2009-01-07 10:49    [W:0.096 / U:6.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site