summaryrefslogtreecommitdiff
path: root/tz/tzfile.5
diff options
context:
space:
mode:
Diffstat (limited to 'tz/tzfile.5')
-rw-r--r--tz/tzfile.5104
1 files changed, 63 insertions, 41 deletions
diff --git a/tz/tzfile.5 b/tz/tzfile.5
index 2f70915..cd4c483 100644
--- a/tz/tzfile.5
+++ b/tz/tzfile.5
@@ -16,6 +16,13 @@ The timezone information files used by
are typically found under a directory with a name like
.IR /usr/share/zoneinfo .
These files use the format described in Internet RFC 8536.
+Each file is a sequence of 8-bit bytes.
+In a file, a binary integer is represented by a sequence of one or
+more bytes in network order (bigendian, or high-order byte first),
+with all bits significant,
+a signed binary integer is represented using two's complement,
+and a boolean is represented by a one-byte binary integer that is
+either 0 (false) or 1 (true).
The format begins with a 44-byte header containing the following fields:
.IP * 2
The magic four-byte ASCII sequence
@@ -30,14 +37,10 @@ or
.IP *
Fifteen bytes containing zeros reserved for future use.
.IP *
-Six four-byte integer values
-written in a standard byte order
-(the high-order byte of the value is written first).
-These values are,
-in order:
+Six four-byte integer values, in the following order:
.RS
.TP
-.I tzh_ttisgmtcnt
+.I tzh_ttisutcnt
The number of UT/local indicators stored in the file.
.TP
.I tzh_ttisstdcnt
@@ -64,7 +67,7 @@ depend on the contents of the header:
.IP * 2
.I tzh_timecnt
four-byte signed integer values sorted in ascending order.
-These values are written in standard byte order.
+These values are written in network byte order.
Each is used as a transition time (as returned by
.BR time (2))
at which the rules for computing local time change.
@@ -87,21 +90,21 @@ entries, each defined as follows:
.nf
.ta .5i +\w'unsigned char\0\0'u
struct ttinfo {
- int32_t tt_gmtoff;
+ int32_t tt_utoff;
unsigned char tt_isdst;
- unsigned char tt_abbrind;
+ unsigned char tt_desigidx;
};
.in -.5i
.fi
.sp
Each structure is written as a four-byte signed integer value for
-.IR tt_gmtoff ,
-in a standard byte order, followed by a one-byte value for
+.IR tt_utoff ,
+in network byte order, followed by a one-byte boolean for
.I tt_isdst
and a one-byte value for
-.IR tt_abbrind .
+.IR tt_desigidx .
In each structure,
-.I tt_gmtoff
+.I tt_utoff
gives the number of seconds to be added to UT,
.I tt_isdst
tells whether
@@ -109,19 +112,28 @@ tells whether
should be set by
.BR localtime (3)
and
-.I tt_abbrind
+.I tt_desigidx
serves as an index into the array of time zone abbreviation bytes
that follow the
.I ttinfo
structure(s) in the file.
+The
+.I tt_utoff
+value is never equal to \-2**31, to let 32-bit clients negate it without
+overflow.
+Also, in realistic applications
+.I tt_utoff
+is in the range [\-89999, 93599] (i.e., more than \-25 hours and less
+than 26 hours); this allows easy support by implementations that
+already support the POSIX-required range [\-24:59:59, 25:59:59].
.IP *
.I tzh_leapcnt
-pairs of four-byte values, written in standard byte order;
+pairs of four-byte values, written in network byte order;
the first value of each pair gives the nonnegative time
(as returned by
.BR time (2))
at which a leap second occurs;
-the second gives the
+the second is a signed integer specifying the
.I total
number of leap seconds to be applied during the time period
starting at the given time.
@@ -130,28 +142,38 @@ Each transition is for one leap second, either positive or negative;
transitions always separated by at least 28 days minus 1 second.
.IP *
.I tzh_ttisstdcnt
-standard/wall indicators, each stored as a one-byte value;
+standard/wall indicators, each stored as a one-byte boolean;
they tell whether the transition times associated with local time types
-were specified as standard time or wall clock time,
-and are used when a timezone file is used in handling POSIX-style
-timezone environment variables.
+were specified as standard time or local (wall clock) time.
.IP *
-.I tzh_ttisgmtcnt
-UT/local indicators, each stored as a one-byte value;
+.I tzh_ttisutcnt
+UT/local indicators, each stored as a one-byte boolean;
they tell whether the transition times associated with local time types
-were specified as UT or local time,
-and are used when a timezone file is used in handling POSIX-style
-timezone environment variables.
+were specified as UT or local time.
+If a UT/local indicator is set, the corresponding standard/wall indicator
+must also be set.
+.PP
+The standard/wall and UT/local indicators were designed for
+transforming a TZif file's transition times into transitions appropriate
+for another time zone specified via a POSIX-style TZ string that lacks rules.
+For example, when TZ="EET\*-2EEST" and there is no TZif file "EET\*-2EEST",
+the idea was to adapt the transition times from a TZif file with the
+well-known name "posixrules" that is present only for this purpose and
+is a copy of the file "Europe/Brussels", a file with a different UT offset.
+POSIX does not specify this obsolete transformational behavior,
+the default rules are installation-dependent, and no implementation
+is known to support this feature for timestamps past 2037,
+so users desiring (say) Greek time should instead specify
+TZ="Europe/Athens" for better historical coverage, falling back on
+TZ="EET\*-2EEST,M3.5.0/3,M10.5.0/4" if POSIX conformance is required
+and older timestamps need not be handled accurately.
.PP
The
.BR localtime (3)
function
-uses the first standard-time
+normally uses the first
.I ttinfo
structure in the file
-(or simply the first
-.I ttinfo
-structure in the absence of a standard-time structure)
if either
.I tzh_timecnt
is zero or the time argument is less than the first transition time recorded
@@ -184,7 +206,7 @@ For version-3-format timezone files, the POSIX-TZ-style string may
use two minor extensions to the POSIX TZ format, as described in
.BR newtzset (3).
First, the hours part of its transition times may be signed and range from
-\*-167 through 167 instead of the POSIX-required unsigned values
+\-167 through 167 instead of the POSIX-required unsigned values
from 0 through 24.
Second, DST is in effect all year if it starts
January 1 at 00:00 and ends December 31 at 24:00 plus the difference
@@ -219,7 +241,7 @@ in the version 1 data block to save space.
Time zone designations should consist of at least three (3)
and no more than six (6) ASCII characters from the set of
alphanumerics,
-.q "-",
+.q "\*-",
and
.q "+".
This is for compatibility with POSIX requirements for
@@ -278,11 +300,11 @@ mishandled by version 2 readers.
Some readers designed for version 2 do not support
permanent daylight saving time, e.g., a TZ string
.q "EST5EDT,0/0,J365/25"
-denoting permanent Eastern Daylight Time (\*-04).
+denoting permanent Eastern Daylight Time (\-04).
As a partial workaround, a writer can substitute standard time
for the next time zone east, e.g.,
.q "AST4"
-for permanent Atlantic Standard Time (\*-04).
+for permanent Atlantic Standard Time (\-04).
.IP *
Some readers ignore the footer, and instead predict future
timestamps from the time type of the last transition.
@@ -296,17 +318,17 @@ As a partial workaround, a writer can output a dummy (no-op)
first transition at an early time.
.IP *
Some readers mishandle timestamps before the first
-transition that has a timestamp not less than -2**31.
+transition that has a timestamp not less than \-2**31.
Readers that support only 32-bit timestamps are likely to be
more prone to this problem, for example, when they process
64-bit transitions only some of which are representable in 32
bits.
As a partial workaround, a writer can output a dummy
-transition at timestamp \*-2**31.
+transition at timestamp \-2**31.
.IP *
Some readers mishandle a transition if its timestamp has
the minimum possible signed 64-bit value.
-Timestamps less than \*-2**59 are not recommended.
+Timestamps less than \-2**59 are not recommended.
.IP *
Some readers mishandle POSIX-style TZ strings that
contain
@@ -327,7 +349,7 @@ These characters are not recommended.
Some readers may mishandle time zone abbreviations that
contain fewer than 3 or more than 6 characters, or that
contain ASCII characters other than alphanumerics,
-.q "-",
+.q "\*-",
and
.q "+".
These abbreviations are not recommended.
@@ -361,18 +383,18 @@ Readers that do not support negative timestamps are likely to
be more prone to this problem.
.IP *
Some readers mishandle time zone abbreviations like
-.q "-08"
+.q "\*-08"
that contain
.q "+",
-.q "-",
+.q "\*-",
or digits.
.IP *
Some readers mishandle UT offsets that are out of the
-traditional range of \*-12 through +12 hours, and so do not
+traditional range of \-12 through +12 hours, and so do not
support locations like Kiritimati that are outside this
range.
.IP *
-Some readers mishandle UT offsets in the range [\*-3599, \*-1]
+Some readers mishandle UT offsets in the range [\-3599, \-1]
seconds from UT, because they integer-divide the offset by
3600 to get 0 and then display the hour part as
.q "+00".