diff --git a/NEWS b/NEWS index 8c17751..5e09773 100644 --- a/NEWS +++ b/NEWS @@ -47,7 +47,9 @@ Unreleased, experimental changes The code now defends against CRLFs in leap-seconds.list. (Thanks to Brian Inglis and Chris Woodbury.) - Changes to commentary + Changes to documentation and commentary + + theory.html discusses leap seconds. (Thanks to Steve Summit.) Nashville's newspapers dueled about the time of day in the 1950s. (Thanks to John Seigenthaler.) diff --git a/theory.html b/theory.html index 1e7df4a..0926aea 100644 --- a/theory.html +++ b/theory.html @@ -21,6 +21,7 @@ database
tz
timezone corresponds to a ruleset that can
have more than two changes per year, these changes need not merely
flip back and forth between two alternatives, and the rules themselves
can change at times.
-Whether and when a timezone changes its
-clock, and even the timezone's notional base offset from UTC, are variable.
+Whether and when a timezone changes its clock,
+and even the timezone's notional base offset from UTC,
+are variable.
It does not always make sense to talk about a timezone's
"base offset", which is not necessarily a single number.
@@ -1072,7 +1074,8 @@ an older zic
.
where time_t
is signed.
+The tz
code and data can account for leap seconds,
+thanks to code contributed by Bradley White.
+However, the leap second support of this package is rarely used directly
+because POSIX requires leap seconds to be ignored and many
+software packages would mishandle leap seconds if they were present.
+Instead, leap seconds are more commonly handled by occasionally adjusting
+the operating system kernel clock as described in
+Precision timekeeping,
+and this package by default installs a leapseconds file
+commonly used by
+NTP
+software that adjusts the kernel clock.
+However, kernel-clock twiddling approximates UTC only roughly,
+and systems needing more-precise UTC can use this package's leap
+second support directly.
+
+The directly-supported mechanism assumes that time_t
+counts of seconds since the POSIX epoch normally include leap seconds,
+as opposed to POSIX time_t
counts which ignore leap seconds.
+This modified timescale is converted to UTC
+at the same point that time zone and DST adjustments are applied –
+namely, at calls to localtime
and analogous functions –
+and the process is driven by leap second information
+stored in alternate versions of the TZif files.
+Because a leap second adjustment may be needed even
+if no time zone correction is desired,
+calls to gmtime
-like functions
+also need to consult a TZif file,
+conventionally named GMT,
+to see whether leap second corrections are needed.
+To convert an application's time_t
timestamps to or from
+POSIX time_t
timestamps (for use when, say,
+embedding or interpreting timestamps in portable
+tar
+files),
+the application can call the utility functions
+time2posix
and posix2time
+included with this package.
+
+If the POSIX-compatible TZif file set is installed
+in a directory whose basename is zoneinfo, the
+leap-second-aware file set is by default installed in a separate
+directory zoneinfo-leaps.
+Although each process can have its own time zone by setting
+its TZ
environment variable, there is no support for some
+processes being leap-second aware while other processes are
+POSIX-compatible; the leap-second choice is system-wide.
+So if you configure your kernel to count leap seconds, you should also
+discard zoneinfo and rename zoneinfo-leaps
+to zoneinfo.
+Alternatively, you can install just one set of TZif files
+in the first place; see the REDO
variable in this package's
+makefile.
+