* gmtime(): Doesn't account for leap seconds?!
@ 1996-04-22 4:00 Edward J Sabol
1996-04-23 4:00 ` Jonathan Kamens
0 siblings, 1 reply; 12+ messages in thread
From: Edward J Sabol @ 1996-04-22 4:00 UTC (permalink / raw)
Cc: sabol
I did some tests and it would seem to me that the C library function gmtime()
doesn't take leap seconds into account when converting from a time_t variable
to a tm structure. This is on the DEC OSF/1 3.2 machine I'm using for
development. Is this a platform-specific bug or is this function not required
by the ISO/ANSI standards to take leap seconds into account on any platform?
If it's the former, are there any Unix operating systems where gmtime() takes
leap seconds into account? If so, which ones?
And before I reinvent the wheel, does anyone have the source code to a
portable version of gmtime() that does in fact take leap seconds into
account?
Please respond by e-mail in addition to posting, if possible.
Thanks,
Ed
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-22 4:00 gmtime(): Doesn't account for leap seconds?! Edward J Sabol
@ 1996-04-23 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Lawrence Kirby
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Jonathan Kamens @ 1996-04-23 4:00 UTC (permalink / raw)
To: Edward J Sabol; +Cc: jik
First of all, gmtime() is governed by POSIX specs, not by ISO or ANSI specs.
Second, in fact, paying attention to leap seconds is a violation of the POSIX
standard. That is, the POSIX definitions of the various time-related
functions ignore leap seconds, and any C library which pays attention to them
is in violation of the standards.
Third, the time function that are in the Linux libc deal with leap seconds,
and I'm sure they're free :-), so you can download the source code to them and
take a look to see if they originate there or if they're actually part of some
other package that is integrated into the Linux libc (I suspect the latter).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-23 4:00 ` Jonathan Kamens
@ 1996-04-24 4:00 ` Lawrence Kirby
1996-04-24 4:00 ` Chuck Karish
1996-04-24 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` gmtime(): Doesn't account for leap seconds?! Chuck Karish
1996-04-25 4:00 ` Geoff Clare
2 siblings, 2 replies; 12+ messages in thread
From: Lawrence Kirby @ 1996-04-24 4:00 UTC (permalink / raw)
In article <4lid0q$itq@jik.israel.net>
jik@annex-1-slip-jik.cam.ov.com "Jonathan Kamens" writes:
>First of all, gmtime() is governed by POSIX specs, not by ISO or ANSI specs.
ANSI C "7.12.3.3 The gmtime function"
POSIX defers to ANSI C for the definition of gmtime(). The tm_sec member
of a struct tm is permitted a range of 0 to 61 under ANSI C so leap
seconds are supported. However ANSI C doesn't define the representation of a
time_t value whereas POSIX, to a great extent, does. I don't know the
exact details but it would be that definition that prevents leap seconds
being supported.
>Second, in fact, paying attention to leap seconds is a violation of the POSIX
>standard. That is, the POSIX definitions of the various time-related
>functions ignore leap seconds, and any C library which pays attention to them
>is in violation of the standards.
>
>Third, the time function that are in the Linux libc deal with leap seconds,
>and I'm sure they're free :-), so you can download the source code to them and
>take a look to see if they originate there or if they're actually part of some
>other package that is integrated into the Linux libc (I suspect the latter).
LINUX is supposedly POSIX compliant. Then by your argument above its standard
library cannot support leap seconds at least not when used in a POSIX
conforming mode.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-24 4:00 ` Lawrence Kirby
1996-04-24 4:00 ` Chuck Karish
@ 1996-04-24 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Chuck Karish
1 sibling, 1 reply; 12+ messages in thread
From: Jonathan Kamens @ 1996-04-24 4:00 UTC (permalink / raw)
In article <830348597snz@genesis.demon.co.uk>, Lawrence Kirby <fred@genesis.demon.co.uk> writes:
|> However ANSI C doesn't define the representation of a
|> time_t value whereas POSIX, to a great extent, does. I don't know the
|> exact details but it would be that definition that prevents leap seconds
|> being supported.
Yes, I believe that's where it occurs. I believe that it specifies the
algorithm by which a time_t value is converted to a date, and that algorithm
assumes that time_t 0 is 1/1/1970 00:00:00 GMT and that time increases in
sixty-second minutes from that point forward forever.
|> LINUX is supposedly POSIX compliant. Then by your argument above its standard
|> library cannot support leap seconds at least not when used in a POSIX
|> conforming mode.
LINUX isn't "POSIX-complaint", per se, since only one Linux distribution
(Linux-FT) has been tested for compliance, and that distribution made numerous
changes to standard Linux software in order to obtain compliance. It's
entirely possible that they ripped out the leap second support in order to
pass the POSIX tests. Or that they didn't try to obtain full POSIX
compliance, and therefore weren't tested in this particular way. Or that the
POSIX tests missed this one :-).
Also, a Linux system without a file recording leap seconds *will* handle time
in a POSIX-compliant way, since if no leap seconds are defined, time will
behave as POSIX requires. It's just that if some goes ahead and adds leap
seconds to the configuration of the system, it will no longer be
POSIX-complaint. Therefore, it wouldn't surprise me at all if Linux-FT passed
the compliance tests simply by not configuring leap seconds, but leaving the
funcionality in so that their users can configure them in (and thereby "break"
POSIX compliance) if they desire.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-24 4:00 ` Jonathan Kamens
@ 1996-04-24 4:00 ` Chuck Karish
1996-04-25 4:00 ` Bill Marcum
0 siblings, 1 reply; 12+ messages in thread
From: Chuck Karish @ 1996-04-24 4:00 UTC (permalink / raw)
In article <4lltpp$een@jik.israel.net>,
Jonathan Kamens <jik@annex-1-slip-jik.cam.ov.com> wrote:
>LINUX isn't "POSIX-complaint", per se, since only one Linux distribution
>(Linux-FT) has been tested for compliance, and that distribution made numerous
>changes to standard Linux software in order to obtain compliance. It's
>entirely possible that they ripped out the leap second support in order to
>pass the POSIX tests. Or that they didn't try to obtain full POSIX
>compliance, and therefore weren't tested in this particular way. Or that the
>POSIX tests missed this one :-).
A version of Linux has been certified to conform to FIPS 151-2. It's
not necessary to speculate about what might have been tested, because
the source code of the NIST POSIX test suite tells the story.
A system that corrects for leap seconds in gmtime() will definitely
fail the NIST test.
>Also, a Linux system without a file recording leap seconds *will* handle time
>in a POSIX-compliant way, since if no leap seconds are defined, time will
>behave as POSIX requires. It's just that if some goes ahead and adds leap
>seconds to the configuration of the system, it will no longer be
>POSIX-complaint. Therefore, it wouldn't surprise me at all if Linux-FT passed
>the compliance tests simply by not configuring leap seconds, but leaving the
>funcionality in so that their users can configure them in (and thereby "break"
>POSIX compliance) if they desire.
The right way to handle this is to provide a separate set of
functions for use in those programs where leap seconds make a
difference.
--
Chuck Karish karish@mindcraft.com
(415) 323-9000 x117 karish@pangea.stanford.edu
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-23 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Lawrence Kirby
@ 1996-04-24 4:00 ` Chuck Karish
1996-04-25 4:00 ` Geoff Clare
2 siblings, 0 replies; 12+ messages in thread
From: Chuck Karish @ 1996-04-24 4:00 UTC (permalink / raw)
In article <4lid0q$itq@jik.israel.net>,
Jonathan Kamens <jik@annex-1-slip-jik.cam.ov.com> wrote:
>First of all, gmtime() is governed by POSIX specs, not by ISO or ANSI specs.
What's your point? ISO has standards for POSIX.1 (9945-1) and for
C (9989). The ISO C standard specifies the behavior of gmtime().
--
Chuck Karish karish@mindcraft.com
(415) 323-9000 x117 karish@pangea.stanford.edu
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-24 4:00 ` Lawrence Kirby
@ 1996-04-24 4:00 ` Chuck Karish
1996-04-25 4:00 ` Mark Brader
1996-04-24 4:00 ` Jonathan Kamens
1 sibling, 1 reply; 12+ messages in thread
From: Chuck Karish @ 1996-04-24 4:00 UTC (permalink / raw)
In article <830348597snz@genesis.demon.co.uk>,
Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
>In article <4lid0q$itq@jik.israel.net>
> jik@annex-1-slip-jik.cam.ov.com "Jonathan Kamens" writes:
>
>>First of all, gmtime() is governed by POSIX specs, not by ISO or ANSI specs.
>
>ANSI C "7.12.3.3 The gmtime function"
>
>POSIX defers to ANSI C for the definition of gmtime(). The tm_sec member
>of a struct tm is permitted a range of 0 to 61 under ANSI C so leap
>seconds are supported. However ANSI C doesn't define the representation of a
>time_t value whereas POSIX, to a great extent, does. I don't know the
>exact details but it would be that definition that prevents leap seconds
>being supported.
The C Standard doesn't consider leap seconds at all. An implementation
can conform whether or not it handles leap seconds.
POSIX.1 says that time() returns the number of seconds since the
Epoch (4.5.1.2), and gives an algorithm relating the result to UCT that
ignores leap seconds (2.2.2.77). Use of this algorithm by the
time manipulation functions of the C Standard is mandated in 8.1.
--
Chuck Karish karish@mindcraft.com
(415) 323-9000 x117 karish@pangea.stanford.edu
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-25 4:00 ` Bill Marcum
@ 1996-04-24 4:00 ` P.Bennett
1996-04-25 4:00 ` When do leap seconds occur? (was: Re: gmtime(): Doesn't account for leap seconds?!) Jonathan Kamens
1 sibling, 0 replies; 12+ messages in thread
From: P.Bennett @ 1996-04-24 4:00 UTC (permalink / raw)
In article <DqECIp.E9n@iglou.com>, bmarcum@iglou.iglou.com (Bill Marcum) writes...
>
>What is the algorithm for leap seconds anyway? Are they used in years
>ending with 00, or only years divisible by 400?
There is no fixed schedule for leap seconds - they are inserted as needed, when
this wobbly old earth gets too far out of sync with the atomic clocks. (or vice
versa). There have been 11 since 1980, I believe (the last one was last Dec.
31.)
Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
Internet: bennett@triumf.ca | of one another only when one can be
Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
or: http:://vancouver-webpages.com/peter/index.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-24 4:00 ` Chuck Karish
@ 1996-04-25 4:00 ` Bill Marcum
1996-04-24 4:00 ` P.Bennett
1996-04-25 4:00 ` When do leap seconds occur? (was: Re: gmtime(): Doesn't account for leap seconds?!) Jonathan Kamens
0 siblings, 2 replies; 12+ messages in thread
From: Bill Marcum @ 1996-04-25 4:00 UTC (permalink / raw)
What is the algorithm for leap seconds anyway? Are they used in years
ending with 00, or only years divisible by 400?
--
Bill Marcum bmarcum@iglou.com
"Even the samurais have teddy bears, and even the teddy bears get drunk"
(don't ask me what it means, it came from the 'fortune' program).
^ permalink raw reply [flat|nested] 12+ messages in thread
* When do leap seconds occur? (was: Re: gmtime(): Doesn't account for leap seconds?!)
1996-04-25 4:00 ` Bill Marcum
1996-04-24 4:00 ` P.Bennett
@ 1996-04-25 4:00 ` Jonathan Kamens
1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Kamens @ 1996-04-25 4:00 UTC (permalink / raw)
In article <DqECIp.E9n@iglou.com>, bmarcum@iglou.iglou.com (Bill Marcum) writes:
|> What is the algorithm for leap seconds anyway? Are they used in years
|> ending with 00, or only years divisible by 400?
There is no "algorithm". A leap second is inserted or removed when the body
which governs such things determines that it is necessary to do so in order to
bring our clocks into sync with the rotation of the Earth.
The Earth's rotation time isn't precisely constant. Leap seconds correct for
the variability.
The newsgroup where discussion of the mechanics of leap seconds is least
inappropriate (I'm not even sure it's appropriate there) is sci.astro, so I've
directed followups there.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-24 4:00 ` Chuck Karish
@ 1996-04-25 4:00 ` Mark Brader
0 siblings, 0 replies; 12+ messages in thread
From: Mark Brader @ 1996-04-25 4:00 UTC (permalink / raw)
Chuck Karish (karish@pangea.Stanford.EDU) writes:
> POSIX.1 says that time() returns the number of seconds since the
> Epoch (4.5.1.2), and gives an algorithm relating the result to UCT that
> ignores leap seconds (2.2.2.77). Use of this algorithm by the
> time manipulation functions of the C Standard is mandated in 8.1.
I may as well point out again that these requirements are mutually
contradictory. As soon as you talk specifically about UTC rather than
some other flavor of UT, you are requiring leap seconds to be taken
into account. However, I'm informed that the intent clearly was to
require that they be ignored.
Someone else asked when leap seconds happen. There is not a pre-set
schedule; it depends on the measured rotation of the Earth. At the
moment they tend to be roughly every 2 years.
--
Mark Brader, msb@sq.com "Logic is logic. That's all I say."
SoftQuad Inc., Toronto -- Oliver Wendell Holmes
My text in this article is in the public domain.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: gmtime(): Doesn't account for leap seconds?!
1996-04-23 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Lawrence Kirby
1996-04-24 4:00 ` gmtime(): Doesn't account for leap seconds?! Chuck Karish
@ 1996-04-25 4:00 ` Geoff Clare
2 siblings, 0 replies; 12+ messages in thread
From: Geoff Clare @ 1996-04-25 4:00 UTC (permalink / raw)
I'm surprised nobody has mentioned the following important point yet:
The POSIX no-leap-second restriction only applies to gmtime(), and to
localtime() and mktime() when used with TZ=UCT0. It allows time-related
functions other than gmtime() to account for leap seconds when TZ has
other values (such as TZ=GMT0BST, or I think even with TZ=GMT0).
--
Geoff Clare <gwc@root.co.uk>
UniSoft Limited, London, England.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~1996-04-25 4:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-04-22 4:00 gmtime(): Doesn't account for leap seconds?! Edward J Sabol
1996-04-23 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Lawrence Kirby
1996-04-24 4:00 ` Chuck Karish
1996-04-25 4:00 ` Mark Brader
1996-04-24 4:00 ` Jonathan Kamens
1996-04-24 4:00 ` Chuck Karish
1996-04-25 4:00 ` Bill Marcum
1996-04-24 4:00 ` P.Bennett
1996-04-25 4:00 ` When do leap seconds occur? (was: Re: gmtime(): Doesn't account for leap seconds?!) Jonathan Kamens
1996-04-24 4:00 ` gmtime(): Doesn't account for leap seconds?! Chuck Karish
1996-04-25 4:00 ` Geoff Clare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox