Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: alt.comp.hardware.pc-homebuilt,comp.lang.c,comp.lang.ada,comp.programming,alt.os.linux.ubuntu Subject: Re: 'Leap Second' to Be Added on New Year's Eve This Year Date: Mon, 02 Jan 2017 15:38:00 -0800 Organization: None to speak of Lines: 40 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="f1ffbb62f7d4ea154aec5923c7307730"; logging-data="11404"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iU8kSxLGV3y/KZ0K97j10" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:+0aPOEtGdvuLcEPum3IX4ll/dJo= sha1:A/aqq+UOBmM18zdAJk5J/S9LmUY= Xref: csiph.com alt.comp.hardware.pc-homebuilt:35509 comp.lang.c:100925 comp.lang.ada:32654 comp.programming:7237 alt.os.linux.ubuntu:194630 Dänk 42Ø writes: > On 01/02/2017 07:46 AM, Keith Thompson wrote: [...] >> The system clock was probably adjusted gradually during the period >> before and after the leap second. > > But since computers store files with Unix time strings, how is is that > a recently saved file shows the correct current time and is not 37 > seconds off? In fact the timestamp of a file created in 1970 *is* 37 seconds off. I don't have any files that old, but the timestamp of a file created in 2016 is now 1 second off, and will be 2 seconds off after the next leap second. I'll bet you didn't notice. As long as timestamps are monotonically increasing, it doesn't significantly matter. If you need to record timestamps from several years ago with higher precision, and allowing for leap seconds, there are other time representations you can use. It just happens that Unix filesystems don't typically use them (though it's entirely possible that there are some I don't know about that do). Relevance to C: The C standard says only that time_t, the type returned by the time() function, is a real time (integer or floating-point) capable of representing times. POSIX specifically says that leap seconds are ignored. This implies, for example, that time(NULL) % 3600 is the number of seconds since the top of the hour, and that system software doesn't have to allow for past leap seconds (which would be inconvenient) or future leap seconds (which would be impossible). [...] -- 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"