Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #29054

Re: mktime

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: mktime
Date 2012-12-07 17:50 -0800
Organization None to speak of
Message-ID <lny5h9nwgn.fsf@nuthaus.mib.org> (permalink)
References (1 earlier) <k9qcil$oh$1@dont-email.me> <lnobi7ortk.fsf@nuthaus.mib.org> <k9saf7$jn$1@news.m-online.net> <k9tk5a$caq$1@news.m-online.net> <k9tpu9$ptf$1@dont-email.me>

Show all headers | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> writes:
> On 12/7/2012 3:39 PM, Heinrich Wolf wrote:
[...]
>> My Fedora 14 man page for mktime in German:
>> ...
>>        Die Elemente der Struktur tm sind:
>>
>>        tm_sec Die  Anzahl  der  Sekunden  nach der vollen Minute,
>> normalerweise im Bereich 0 bis 59, jedoch in Ausnahmefällen bis 61 um
>> Schaltsekunden zu
>>               erlauben.
>> ...
>> Translated into English:
>> ...
>>        The elements of struct tm are:
>>
>>        tm_sec The number of seconds after the full minute, normally in
>> the range 0 to 59, but in exceptional cases up to 61 in order to allow
>> leap seconds.
>> ...
>>
>> I searched for leap seconds on 2 different systems: Fedora 14 Linux, and
>> Windows XP with Borland C++Builder 5.
>> I expected the calculation localtime(mktime(1970-1-2 00-00-00) + 10000 *
>> 24 * 60 * 60 seconds) to result in a tm struct with some odd seconds,
>> but on both systems I got 1997-05-20 01-00-00
>
>      I remember seeing the [0..61] range for tm_sec long ago, and
> perhaps it still persists in some non-C documents.  Even in the
> original 1989 ANSI C Standard, though, the range was [0..60] in
> keeping with the fact that leap seconds are added (or removed)
> one at a time, never two at once.

The 1990 ISO C standard specifies a range of [0, 61] for tm_sec:

    int tm_sec;  /* seconds after the minute -- [0, 61] */

with a footnote:

    The range [0,61] for tm_sec allows for as many as two leap seconds.

C99 changes the range to [0, 60] and changes the footnote to:

    The range [0, 60] for tm_sec allows for a positive leap second.

There's no mention of the change in the C99 rationale.

I've heard (not sure where) that the [0, 61] range in C90 was
the result of a misunderstanding; if it were necessary to have
two leap seconds in a year (which hasn't happened so far) they'd
be added at the end of June and the end of December.  I *guess*
that if more than two were required, they'd be spread more or less
evenly through the year.

Are you *sure* that the 1989 ANSI standard specifies [0, 60]?
If so, that would be an inconsistency between ANSI C89 and ISO C90,
and I didn't think there were any.

Interestingly, a 1988 ANSI C draft ("ansi.c.txt", I'm not sure
where I got it) shows a range of [0, 60].

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

mktime Anders Wegge Keller <wegge@wegge.dk> - 2012-12-06 15:25 +0100
  Re: mktime James Kuyper <jameskuyper@verizon.net> - 2012-12-06 09:53 -0500
  Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 10:11 -0500
    Re: mktime Anders Wegge Keller <wegge@wegge.dk> - 2012-12-06 17:40 +0100
      Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 14:20 -0500
        Re: mktime Keith Thompson <kst-u@mib.org> - 2012-12-06 12:28 -0800
          Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 17:36 -0500
            Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 17:42 -0500
    Re: mktime Keith Thompson <kst-u@mib.org> - 2012-12-06 12:20 -0800
      Re: mktime Anders Wegge Keller <wegge@wegge.dk> - 2012-12-06 21:37 +0100
      Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-07 09:48 +0100
        Re: mktime James Kuyper <jameskuyper@verizon.net> - 2012-12-07 08:08 -0500
          Re: mktime "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-12-07 09:23 -0800
            Re: mktime James Kuyper <jameskuyper@verizon.net> - 2012-12-07 13:14 -0500
            Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-07 13:46 -0500
            Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-07 19:59 +0100
            Re: mktime Robert Wessel <robertwessel2@yahoo.com> - 2012-12-07 15:50 -0600
        Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-07 21:39 +0100
          Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-07 17:17 -0500
            Re: mktime Keith Thompson <kst-u@mib.org> - 2012-12-07 17:50 -0800
              Re: mktime Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-08 08:34 -0500
          Re: mktime pacman@kosh.dhis.org (Alan Curry) - 2012-12-07 22:44 +0000
            Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-08 10:31 +0100
              Re: mktime pacman@kosh.dhis.org (Alan Curry) - 2012-12-08 20:50 +0000
                Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-09 11:39 +0100
                Re: mktime pacman@kosh.dhis.org (Alan Curry) - 2012-12-09 19:47 +0000
                Re: mktime "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-10 09:51 +0100
                Re: mktime sla29970@gmail.com - 2012-12-09 08:41 -0800

csiph-web