Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c,comp.programming,alt.comp.os.windows-10,alt.os.linux.ubuntu Subject: Re: 'Leap Second' to Be Added on New Year's Eve This Year Date: Fri, 30 Dec 2016 14:37:18 -0800 Organization: None to speak of Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="9cde9db04945311bb4638cac08ff52e5"; logging-data="15912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FcVUGc0e4wwiI1GkmLPHq" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:X+fbKuqkATnVMO4sjgGuxGKTrcg= sha1:aUkFJDkiC/Ov1NlQ/sl/2tuKbdM= Xref: csiph.com comp.lang.c:100709 comp.programming:7201 alt.comp.os.windows-10:32243 alt.os.linux.ubuntu:194591 Mark Lloyd writes: > On 12/30/2016 10:16 AM, Ken Brody wrote: > > [snip] > >> C already handles this. >> >> My describes the "tm_sec" entry of "struct tm" with: >> >> int tm_sec; /* Seconds. [0-60] (1 leap second) */ >> > > I thought the time was actually stored in a single integer, then as > appropriate, decoded into that structure. The time is stored in a time_t value returned by the time() function. The time_t type is required to be a real type (integer or floating-point, not complex) capable of representing times. (On many systems it's a signed integer representing seconds since 1970-01-01 00:00:00 UTC.) > Does that single integer have different values for 23:59:69 and for > 23:59:60? If not, how would tm_sec ever be 60? The standard doesn't require the functions to handle leap seconds. In the presence of a leap second, 23:59:59 and 23:59:60 *may* correspond to different time_t values. > The way I heard it is that that one second (23:59:59 GMT) would actually > last 2 seconds (it would take 2 seconds for the clock to change, instead > of the usual 1). If a program was requesting time() once a second, it > would get the same value twice agt the end of the year. It depends on the OS. On some systems, there is no 23:59:60, but the progression of values returned by time_t is stretched out over some longer period surrounding 00:00:00. > BTW, the "end of the year" should come at 6PM here, since this is the > Central time zone. I should be able to watch the clock on my webpage > (updated by Javascript) show 5:59:59 for 2 seconds. That depends on how Javascript, or the code your web page is running, handles leap seconds. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"