On Tuesday, July 5, 2005 at 6:59:04 PM +0200, Hrvoje Niksic wrote:

> Am I completely off the mark, or can mktime_from_utc (or in fact
> timegm) be replaced by something as simple as the following? Or is it
> too good to be true?

It returns a number of seconds since epoch neglecting leap seconds. This
number is later given to the system for file timestamps, display, and
such. I believe this can unfortunately be wrong by about 22s on
platforms without timegm() but counting leap seconds. Untested though.

It seems many platforms directly or optionally account for leap seconds.
Example Linux Woody by default neglects but optionally accounts leap
seconds when timezone info comes from the right directory.

| $ TZ=UTC       date --date "9 Sep 2001 1:46:40 UTC" +%s
| 1000000000
| $ TZ=right/UTC date --date "9 Sep 2001 1:46:40 UTC" +%s
| 1000000022

The first is the common Posix simplification, the later is The Truth.


By the way: After 7 years of stability, the IERS announced officialy
that the next added leap second will be December 31 2005 23:59:60 UTC.


Alain.

Reply via email to