Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

difftime() and leap seconds

45 views
Skip to first unread message

Dann Corbit

unread,
Sep 28, 1998, 3:00:00 AM9/28/98
to
Is difftime() required to know about leap seconds and provide an accurate
result?
--
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ ftp: ftp://rtfm.mit.edu, C-FAQ Book: ISBN 0-201-84519-9
Try "C Programming: A Modern Approach" ISBN 0-393-96945-2
Want Software? Algorithms? Pubs? http://www.infoseek.com

Paul Eggert

unread,
Sep 28, 1998, 3:00:00 AM9/28/98
to
"Dann Corbit" <dco...@solutionsiq.com> writes:

>Is difftime() required to know about leap seconds and provide an accurate
>result?

No. It's not required, and most hosts don't do it.
Arguably, POSIX.1 forbids it.

Nick Maclaren

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
In article <6upss9$2ot$1...@shade.twinsun.com>,

Yes, quite, except that I would have said "INarguably, POSIX.1 forbids it."


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email: nm...@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679

Dann Corbit

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
Nick Maclaren wrote in message <6uq7b8$467$1...@pegasus.csx.cam.ac.uk>...

>In article <6upss9$2ot$1...@shade.twinsun.com>,
>Paul Eggert <egg...@twinsun.com> wrote:
>>"Dann Corbit" <dco...@solutionsiq.com> writes:
>>
>>>Is difftime() required to know about leap seconds and provide an accurate
>>>result?
>>
>>No. It's not required, and most hosts don't do it.
>>Arguably, POSIX.1 forbids it.
>
>Yes, quite, except that I would have said "INarguably, POSIX.1 forbids it."

Isn't that a bit like the famous Indiana State Legislature and pi incident?
The truth[1] is that there are occasionally 86401 seconds in a day, and even
more rarely 86402 [Though I have never seen a double leap second, it is
supposed to be allowed].

[1] Also mandated by international standards bodies, specifically
coordinated universal time (UCT) mandates this.

Markus Kuhn

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
"Dann Corbit" <dco...@solutionsiq.com> writes:
|> The truth[1] is that there are occasionally 86401 seconds in a day, and even
|> more rarely 86402 [Though I have never seen a double leap second, it is
|> supposed to be allowed].
|>
|> [1] Also mandated by international standards bodies, specifically
|> coordinated universal time (UCT) mandates this.

The "double leap second" is complete nonsense. It never existed outside the
ANSI C standard and never will. It was introduced by the ANSI C 89 committee
to document its problems understanding UTC issues. Someone heard that there
are two prefered dates for leap seconds per year and this got munched up to
the false rumour that UTC days can be up to 86402 seconds long. The
definition of UTC, which requires that |UTC-UT1| < 0.9 s all the time,
obviously makes double leap seconds mathematically impossible.

Highly recommended reading:

Original references (the official UTC definition and an excellent
paper about UTC):

http://www.cl.cam.ac.uk/~mgk25/volatile/ITU-R-TF.460-4.pdf
http://www.cl.cam.ac.uk/~mgk25/volatile/astronomical-time.pdf

Detailed proposal for a C API that handles leap seconds correctly (and
fixes many other problems in <time.h>):

http://www.cl.cam.ac.uk/~mgk25/c-time/

Markus

--
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org, home page: <http://www.cl.cam.ac.uk/~mgk25/>

Dann Corbit

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
Markus Kuhn wrote in message <6urcfr$s01$1...@pegasus.csx.cam.ac.uk>...

>"Dann Corbit" <dco...@solutionsiq.com> writes:
>|> The truth[1] is that there are occasionally 86401 seconds in a day, and
even
>|> more rarely 86402 [Though I have never seen a double leap second, it is
>|> supposed to be allowed].
>|>
>|> [1] Also mandated by international standards bodies, specifically
>|> coordinated universal time (UCT) mandates this.
>
>The "double leap second" is complete nonsense. It never existed outside the
>ANSI C standard and never will. It was introduced by the ANSI C 89
committee
>to document its problems understanding UTC issues. Someone heard that there
>are two prefered dates for leap seconds per year and this got munched up to
>the false rumour that UTC days can be up to 86402 seconds long. The
>definition of UTC, which requires that |UTC-UT1| < 0.9 s all the time,
>obviously makes double leap seconds mathematically impossible.
>
>Highly recommended reading:
>
>Original references (the official UTC definition and an excellent
>paper about UTC):
>
> http://www.cl.cam.ac.uk/~mgk25/volatile/ITU-R-TF.460-4.pdf
> http://www.cl.cam.ac.uk/~mgk25/volatile/astronomical-time.pdf
>
>Detailed proposal for a C API that handles leap seconds correctly (and
>fixes many other problems in <time.h>):
>
> http://www.cl.cam.ac.uk/~mgk25/c-time/
This is a very excellent proposal, and very helpful if it should come to
pass. However, I would like to see at least one function added:
double xtime_diff(xtime start, xtime end);
Or [even better -- like SQL]
double diff_xtime(datepart unit, xtime start, xtime end);
Where datepart is in:
{years, quarters, months, days, weeks, hours, minutes, seconds,
milliseconds}
0 new messages