[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <496479EA.1020207@davidnewall.com>
Date: Wed, 07 Jan 2009 20:16:18 +1030
From: David Newall <davidn@...idnewall.com>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
CC: Nick Andrew <nick@...k-andrew.net>,
Linas Vepstas <linasvepstas@...il.com>, david@...g.hm,
Kyle Moffett <kyle@...fetthome.net>,
Ben Goodger <goodgerster@...il.com>,
Robert Hancock <hancockr@...w.ca>,
linux-kernel@...r.kernel.org,
"Jeffrey J. Kosowsky" <jeff@...owsky.org>,
MentalMooMan <slashdot@...eshallam.info>,
Travis Crump <pretzalz@...hhouse.org>, burdell@...ntheinter.net
Subject: Re: 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@...auji:~/timetest$ cat tz
Zone testzone 0:00 0 XXX/YYY
davidn@...auji:~/timetest$ cat leapseconds
Leap 2008 Dec 31 23:59:59 + S
davidn@...auji:~/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@...auji:~/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@...auji:~/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.)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists