[PROPOSED] Document POSIX versions more carefully

Since the next POSIX will require support for TZDB Zone names in the TZ environment variable, be more careful about phrases like “POSIX-like TZ strings” in comments and documentation. Call them “POSIX.1-2017-like TZ strings” instead, to make it clearer that they’re the traditional POSIX form like TZ='GMT0BST,M3.5.0/1,M10.5.0' instead of the TZDB form like TZ='Europe/London'. --- Makefile | 19 ++++++++++--------- etcetera | 2 +- localtime.c | 16 +++++++++------- newstrftime.3 | 4 ++-- newtzset.3 | 4 ++-- private.h | 2 +- theory.html | 30 +++++++++++++++--------------- tz-link.html | 2 +- tzfile.5 | 28 +++++++++++++++------------- tzfile.h | 6 +++--- tzselect.ksh | 6 +++--- zic.8 | 10 +++++----- zic.c | 9 +++++---- 13 files changed, 72 insertions(+), 66 deletions(-) diff --git a/Makefile b/Makefile index 97a17314..d48354c7 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ DATAFORM= main LOCALTIME= Factory -# The POSIXRULES macro controls interpretation of POSIX-like TZ +# The POSIXRULES macro controls interpretation of POSIX-2017.1-like TZ # settings like TZ='EET-2EEST' that lack DST transition rules. # If POSIXRULES is '-', no template is installed; this is the default. # Any other value for POSIXRULES is obsolete and should not be relied on, as: @@ -274,7 +274,7 @@ LDLIBS= # -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory; # the default is system-supplied, typically "/usr/lib/locale" # -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified -# DST transitions for POSIX-style TZ strings lacking them, +# DST transitions for POSIX.1-2017-style TZ strings lacking them, # in the usual case where POSIXRULES is '-'. If not specified, # TZDEFRULESTRING defaults to US rules for future DST transitions. # This mishandles some past timestamps, as US DST rules have changed. @@ -340,9 +340,10 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ # guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this. # Similarly, if your system has a "zone abbreviation" field, define # -DTM_ZONE=tm_zone -# and define NO_TM_ZONE to suppress any guessing. Although these two fields -# not required by POSIX, a future version of POSIX is planned to require them -# and they are widely available on GNU/Linux and BSD systems. +# and define NO_TM_ZONE to suppress any guessing. +# Although these two fields are not required by POSIX.1-2017, +# POSIX 202x/D4 requires them and they are widely available +# on GNU/Linux and BSD systems. # # The next batch of options control support for external variables # exported by tzcode. In practice these variables are less useful @@ -352,7 +353,7 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ # # -DHAVE_TZNAME=0 # do not support "tzname" # # -DHAVE_TZNAME=1 # support "tzname", which is defined by system library # # -DHAVE_TZNAME=2 # support and define "tzname" -# # to the "CFLAGS=" line. "tzname" is required by POSIX 1988 and later. +# # to the "CFLAGS=" line. "tzname" is required by POSIX.1-1988 and later. # # If not defined, the code attempts to guess HAVE_TZNAME from other macros. # # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause # # crashes when combined with some platforms' standard libraries, @@ -362,8 +363,8 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ # # -DUSG_COMPAT=0 # do not support # # -DUSG_COMPAT=1 # support, and variables are defined by system library # # -DUSG_COMPAT=2 # support and define variables -# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by -# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later. +# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by Unix +# # Systems Group code and are required by POSIX.1-2008 and later (with XSI). # # If not defined, the code attempts to guess USG_COMPAT from other macros. # # # # To support the external variable "altzone", add @@ -427,7 +428,7 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ # The name of a POSIX-like library archiver, its flags, C compiler, # linker flags, and 'make' utility. Ordinarily the defaults suffice. -# The commented-out values are the defaults specified by POSIX 202x/D3. +# The commented-out values are the defaults specified by POSIX.1-202x/D4. #AR = ar #ARFLAGS = -rv #CC = c17 diff --git a/etcetera b/etcetera index 865a220c..29fbed9b 100644 --- a/etcetera +++ b/etcetera @@ -5,7 +5,7 @@ # These entries are for uses not otherwise covered by the tz database. # Their main practical use is for platforms like Android that lack -# support for POSIX-style TZ strings. On such platforms these entries +# support for POSIX.1-2017-style TZ strings. On such platforms these entries # can be useful if the timezone database is wrong or if a ship or # aircraft at sea is not in a timezone. diff --git a/localtime.c b/localtime.c index 7613769f..02cc5ee5 100644 --- a/localtime.c +++ b/localtime.c @@ -7,7 +7,7 @@ /* ** Leap second handling from Bradley White. -** POSIX-style TZ environment variable handling from Guy Harris. +** POSIX.1-1988 style TZ environment variable handling from Guy Harris. */ /*LINTLIBRARY*/ @@ -106,7 +106,7 @@ static char const UNSPEC[] = "-00"; for ttunspecified to work without crashing. */ enum { CHARS_EXTRA = max(sizeof UNSPEC, 2) - 1 }; -/* Limit to time zone abbreviation length in POSIX-style TZ strings. +/* Limit to time zone abbreviation length in POSIX.1-2017-style TZ strings. This is distinct from TZ_MAX_CHARS, which limits TZif file contents. */ #ifndef TZNAME_MAXIMUM # define TZNAME_MAXIMUM 255 @@ -935,7 +935,8 @@ getoffset(register const char *strp, int_fast32_t *const offsetp) /* ** Given a pointer into a timezone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". +** date[/time]. See POSIX Base Definitions section 8.3 variable TZ +# for the format of "date" and "time". ** If a valid rule is not found, return NULL. ** Otherwise, return a pointer to the first character not part of the rule. */ @@ -1079,7 +1080,7 @@ transtime(const int year, register const struct rule *const rulep, } /* -** Given a POSIX section 8-style TZ string, fill in the rule tables as +** Given a POSIX.1-2017-style TZ string, fill in the rule tables as ** appropriate. */ @@ -1312,8 +1313,8 @@ tzparse(const char *name, struct state *sp, struct state const *basep) /* ** Transitions from DST to DDST ** will effectively disappear since - ** POSIX provides for only one DST - ** offset. + ** POSIX.1-2017 provides for only one + ** DST offset. */ if (isdst && !sp->ttis[j].tt_ttisstd) { sp->ats[i] += dstoffset - @@ -1483,7 +1484,8 @@ tzfree(timezone_t sp) ** ** If successful and SETNAME is nonzero, ** set the applicable parts of tzname, timezone and altzone; -** however, it's OK to omit this step if the timezone is POSIX-compatible, +** however, it's OK to omit this step +** if the timezone is compatible with POSIX.1-2017 ** since in that case tzset should have already done this step correctly. ** SETNAME's type is int_fast32_t for compatibility with gmtsub, ** but it is actually a boolean and its value should be 0 or 1. diff --git a/newstrftime.3 b/newstrftime.3 index 9fc68471..704318ea 100644 --- a/newstrftime.3 +++ b/newstrftime.3 @@ -91,11 +91,11 @@ as specified by brackets in the description. If a bracketed member name is followed by .q + , .B strftime -can use the named member even though POSIX-2017 does not list it; +can use the named member even though POSIX.1-2017 does not list it; if the name is followed by .q \*- , .B strftime -ignores the member even though POSIX-2017 lists it +ignores the member even though POSIX.1-2017 lists it which means portable code should set it. For portability, .BI * timeptr diff --git a/newtzset.3 b/newtzset.3 index 5d973749..b1384f32 100644 --- a/newtzset.3 +++ b/newtzset.3 @@ -216,7 +216,7 @@ except that POSIX.1-2017 does not allow a leading sign (\c .q "\*-" or .q "+" ). -As an extension to POSIX-1.2017, the hours part of +As an extension to POSIX.1-2017, the hours part of .I time can range from \-167 through 167; this allows for unusual rules such as @@ -230,7 +230,7 @@ is not given, is Here are some examples of .I TZ values that directly specify the timezone; they use some of the -extensions to POSIX-1.2017. +extensions to POSIX.1-2017. .TP .B EST5 stands for US Eastern Standard diff --git a/private.h b/private.h index b3d563d5..0dac6af4 100644 --- a/private.h +++ b/private.h @@ -973,7 +973,7 @@ enum { /* How many years to generate (in zic.c) or search through (in localtime.c). This is two years larger than the obvious 400, to avoid edge cases. - E.g., suppose a non-POSIX rule applies from 2012 on and has transitions + E.g., suppose a non-POSIX.1-2017 rule applies from 2012 on with transitions in March and September, plus one-off transitions in November 2013. If zic looked only at the last 400 years, it would set max_year=2413, with the intent that the 400 years 2014 through 2413 will be repeated. diff --git a/theory.html b/theory.html index 0fb8d66a..318b6c25 100644 --- a/theory.html +++ b/theory.html @@ -95,7 +95,7 @@ Group Base Specifications Issue 7</a>, IEEE Std 1003.1-2017, 2018 Edition. Because the database's scope encompasses real-world changes to civil timekeeping, its model for describing time is more complex than the -standard and daylight saving times supported by POSIX. +standard and daylight saving times supported by POSIX.1-2017. A <code><abbr>tz</abbr></code> 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 @@ -187,7 +187,7 @@ in decreasing order of importance: href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> letters, '<code>.</code>', '<code>-</code>' and '<code>_</code>'. Do not use digits, as that might create an ambiguity with <a - href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX + href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX.1-2017 <code>TZ</code> strings</a>. A file name component must not exceed 14 characters or start with '<code>-</code>'. @@ -378,7 +378,7 @@ nowadays distributions typically use it and no great weight should be attached to whether a link is defined in <code>backward</code> or in some other file. The source file <code>etcetera</code> defines names that may be useful -on platforms that do not support POSIX-style <code>TZ</code> strings; +on platforms that do not support POSIX.1-2017-style <code>TZ</code> strings; no other source file other than <code>backward</code> contains links to its zones. One of <code>etcetera</code>'s names is <code>Etc/UTC</code>, @@ -426,7 +426,7 @@ in decreasing order of importance: expression <code>[-+[:alnum:]]{3,6}</code> should match the abbreviation. This guarantees that all abbreviations could have been specified by a - POSIX <code>TZ</code> string. + POSIX.1-2017 <code>TZ</code> string. </p> </li> <li> @@ -775,7 +775,7 @@ href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanes the Western 06:00 to be 12:00. These practices are largely outside the scope of the <code><abbr>tz</abbr></code> code and data, which provide only limited support for date and time localization - such as that required by POSIX. + such as that required by POSIX.1-2017. If <abbr>DST</abbr> is not used a different time zone can often do the trick; for example, in Kenya a <code>TZ</code> setting like <code><-03>3</code> or <code>America/Cayenne</code> starts @@ -872,23 +872,23 @@ input is occasionally extended, and a platform may still be shipping an older <code>zic</code>. </p> -<h3 id="POSIX">POSIX properties and limitations</h3> +<h3 id="POSIX">POSIX.1-2017 properties and limitations</h3> <ul> <li> <p> - In POSIX, time display in a process is controlled by the + In POSIX.1-2017, time display in a process is controlled by the environment variable <code>TZ</code>. - Unfortunately, the POSIX + Unfortunately, the POSIX.1-2017 <code>TZ</code> string takes a form that is hard to describe and is error-prone in practice. - Also, POSIX <code>TZ</code> strings cannot deal with daylight + Also, POSIX.1-2017 <code>TZ</code> strings cannot deal with daylight saving time rules not based on the Gregorian calendar (as in Morocco), or with situations where more than two time zone abbreviations or <abbr>UT</abbr> offsets are used in an area. </p> <p> - The POSIX <code>TZ</code> string takes the following form: + The POSIX.1-2017 <code>TZ</code> string takes the following form: </p> <p> @@ -955,7 +955,7 @@ an older <code>zic</code>. </dl> <p> - Here is an example POSIX <code>TZ</code> string for New + Here is an example POSIX.1-2017 <code>TZ</code> string for New Zealand after 2007. It says that standard time (<abbr>NZST</abbr>) is 12 hours ahead of <abbr>UT</abbr>, and that daylight saving time @@ -966,7 +966,7 @@ an older <code>zic</code>. <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre> <p> - This POSIX <code>TZ</code> string is hard to remember, and + This POSIX.1-2017 <code>TZ</code> string is hard to remember, and mishandles some timestamps before 2008. With this package you can use this instead: </p> @@ -1004,7 +1004,7 @@ an older <code>zic</code>. limit phone calls to off-peak hours. </li> <li> - POSIX provides no convenient and efficient way to determine + POSIX.1-2017 provides no convenient and efficient way to determine the <abbr>UT</abbr> offset and time zone abbreviation of arbitrary timestamps, particularly for timezones that do not fit into the POSIX model. @@ -1031,14 +1031,14 @@ an older <code>zic</code>. </li> </ul> -<h3 id="POSIX-extensions">Extensions to POSIX in the +<h3 id="POSIX-extensions">Extensions to POSIX.1-2017 in the <code><abbr>tz</abbr></code> code</h3> <ul> <li> <p> The <code>TZ</code> environment variable is used in generating the name of a file from which time-related information is read - (or is interpreted à la POSIX); <code>TZ</code> is no longer + (or is interpreted à la POSIX.1-2017); <code>TZ</code> is no longer constrained to be a string containing abbreviations and numeric data as described <a href="#POSIX">above</a>. The file's format is <dfn><abbr>TZif</abbr></dfn>, diff --git a/tz-link.html b/tz-link.html index 5840f48f..c6181d92 100644 --- a/tz-link.html +++ b/tz-link.html @@ -114,7 +114,7 @@ Indiana, which switched from central to eastern time in 1991 and switched back in 2006. To use the database on an extended <a href="https://en.wikipedia.org/wiki/POSIX"><abbr -title="Portable Operating System Interface">POSIX</abbr></a> +title="Portable Operating System Interface">POSIX</abbr>.1-2017</a> implementation set the <code><abbr>TZ</abbr></code> environment variable to the location's full name, e.g., <code><abbr>TZ</abbr>="America/New_York"</code>.</p> diff --git a/tzfile.5 b/tzfile.5 index 55280282..867348d6 100644 --- a/tzfile.5 +++ b/tzfile.5 @@ -85,7 +85,7 @@ described in the file is associated with the time period starting with the same-indexed transition time and continuing up to but not including the next transition time. (The last time type is present only for consistency checking with the -POSIX-style TZ string described below.) +POSIX.1-2017-style TZ string described below.) These values serve as indices into the next field. .IP \(bu .B tzh_typecnt @@ -186,7 +186,8 @@ 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 another time zone specified via +a POSIX.1-2017-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 @@ -215,13 +216,14 @@ the above header and data are followed by a second header and data, identical in format except that eight bytes are used for each transition time or leap second time. (Leap second counts remain four bytes.) -After the second header and data comes a newline-enclosed, -POSIX-TZ-environment-variable-style string for use in handling instants +After the second header and data comes a newline-enclosed string +in the style of the contents of a POSIX.1-2017 TZ environment variable, +for use in handling instants after the last transition time stored in the file or for all instants if the file has no transitions. -The POSIX-style TZ string is empty (i.e., nothing between the newlines) -if there is no POSIX-style representation for such instants. -If nonempty, the POSIX-style TZ string must agree with the local time +The TZ string is empty (i.e., nothing between the newlines) +if there is no POSIX.1-2017-style representation for such instants. +If nonempty, the TZ string must agree with the local time type after the last transition time if present in the eight-byte data; for example, given the string .q "WET0WEST,M3.5.0/1,M10.5.0" @@ -233,8 +235,8 @@ Also, if there is at least one transition, time type 0 is associated with the time period from the indefinite past up to but not including the earliest transition time. .SS Version 3 format -For version-3-format timezone files, the POSIX-TZ-style string may -use two minor extensions to the POSIX TZ format, as described in +For version-3-format timezone files, the TZ string may +use two minor extensions to the POSIX.1-2017 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 @@ -352,7 +354,7 @@ version 2+ data even if the reader's native timestamps have only .IP \(bu Some readers designed for version 2 might mishandle timestamps after a version 3 or higher file's last transition, because -they cannot parse extensions to POSIX in the TZ-like string. +they cannot parse extensions to POSIX.1-2017 in the TZ-like string. As a partial workaround, a writer can output more transitions than necessary, so that only far-future timestamps are mishandled by version 2 readers. @@ -403,7 +405,7 @@ Some readers mishandle a transition if its timestamp has the minimum possible signed 64-bit value. Timestamps less than \-2**59 are not recommended. .IP \(bu -Some readers mishandle POSIX-style TZ strings that +Some readers mishandle TZ strings that contain .q "<" or @@ -431,12 +433,12 @@ Some readers mishandle TZif files that specify daylight-saving time UT offsets that are less than the UT offsets for the corresponding standard time. These readers do not support locations like Ireland, which -uses the equivalent of the POSIX TZ string +uses the equivalent of the TZ string .q "IST\*-1GMT0,M10.5.0,M3.5.0/1", observing standard time (IST, +01) in summer and daylight saving time (GMT, +00) in winter. As a partial workaround, a writer can output data for the -equivalent of the POSIX TZ string +equivalent of the TZ string .q "GMT0IST,M3.5.0/1,M10.5.0", thus swapping standard and daylight saving time. Although this workaround misidentifies which part of the year diff --git a/tzfile.h b/tzfile.h index 21ae37c1..3155010e 100644 --- a/tzfile.h +++ b/tzfile.h @@ -78,11 +78,11 @@ struct tzhead { ** time uses 8 rather than 4 chars, ** then a POSIX-TZ-environment-variable-style string for use in handling ** instants after the last transition time stored in the file -** (with nothing between the newlines if there is no POSIX representation for -** such instants). +** (with nothing between the newlines if there is no POSIX.1-2017 +** representation for such instants). ** ** If tz_version is '3' or greater, the above is extended as follows. -** First, the POSIX TZ string's hour offset may range from -167 +** First, the TZ string's hour offset may range from -167 ** through 167 as compared to the POSIX-required 0 through 24. ** Second, its DST start time may be January 1 at 00:00 and its stop ** time December 31 at 24:00 plus the difference between DST and diff --git a/tzselect.ksh b/tzselect.ksh index c56bc822..38941bbc 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -438,7 +438,7 @@ while eval ' doselect '"$quoted_continents"' \ "coord - I want to use geographical coordinates." \ - "TZ - I want to specify the timezone using the POSIX TZ format." \ + "TZ - I want to specify the timezone using a POSIX.1-2017 TZ string." \ "time - I know local time already." \ "now - Like \"time\", but configure only for timestamps from now on." continent=$select_result @@ -462,7 +462,7 @@ while case $continent in TZ) - # Ask the user for a POSIX TZ string. Check that it conforms. + # Ask the user for a POSIX.1-2017 TZ string. Check that it conforms. check_POSIX_TZ_string=' BEGIN { tz = substr(ARGV[1], 2) @@ -492,7 +492,7 @@ while read tz $AWK "$check_POSIX_TZ_string" ="$tz" do - say >&2 "'$tz' is not a conforming POSIX timezone string." + say >&2 "'$tz' is not a conforming POSIX.1-2017 timezone string." done TZ_for_date=$tz;; *) diff --git a/zic.8 b/zic.8 index 2f274d7b..0ad373a2 100644 --- a/zic.8 +++ b/zic.8 @@ -171,7 +171,7 @@ boundaries, particularly if causes a TZif file to contain explicit entries for .RI pre- hi transitions rather than concisely representing them -with an extended POSIX TZ string. +with an extended POSIX.1-2017 TZ string. Also see the .B "\*-b slim" option for another way to shrink output size. @@ -181,10 +181,10 @@ Generate redundant trailing explicit transitions for timestamps that occur less than .I hi seconds since the Epoch, even though the transitions could be -more concisely represented via the extended POSIX TZ string. +more concisely represented via the extended POSIX.1-2017 TZ string. This option does not affect the represented timestamps. Although it accommodates nonstandard TZif readers -that ignore the extended POSIX TZ string, +that ignore the extended POSIX.1-2017 TZ string, it increases the size of the altered output files. .TP .BI "\*-t " file @@ -245,10 +245,10 @@ for .PP The output file does not contain all the information about the long-term future of a timezone, because the future cannot be summarized as -an extended POSIX TZ string. For example, as of 2023 this problem +an extended POSIX.1-2017 TZ string. For example, as of 2023 this problem occurs for Morocco's daylight-saving rules, as these rules are based on predictions for when Ramadan will be observed, something that -an extended POSIX TZ string cannot represent. +an extended POSIX.1-2017 TZ string cannot represent. .PP The output contains data that may not be handled properly by client code designed for older diff --git a/zic.c b/zic.c index 70e8f0c7..00f00e30 100644 --- a/zic.c +++ b/zic.c @@ -2982,7 +2982,7 @@ rule_cmp(struct rule const *a, struct rule const *b) return a->r_dayofmonth - b->r_dayofmonth; } -/* Store into RESULT a POSIX TZ string that represent the future +/* Store into RESULT a POSIX.1-2017 TZ string that represent the future predictions for the zone ZPFIRST with ZONECOUNT entries. Return a compatibility indicator (a TZDB release year) if successful, a negative integer if no such TZ string exissts. */ @@ -3177,7 +3177,8 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount) if (noise) { if (!*envvar) warning("%s %s", - _("no POSIX environment variable for zone"), + _("no POSIX.1-2017 environment variable" + " for zone"), zpfirst->z_name); else if (compat != 0) { /* Circa-COMPAT clients, and earlier clients, might @@ -3440,8 +3441,8 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount) } if (do_extend) { /* - ** If we're extending the explicitly listed observations - ** for 400 years because we can't fill the POSIX-TZ field, + ** If we're extending the explicitly listed observations for + ** 400 years because we can't fill the POSIX.1-2017 TZ field, ** check whether we actually ended up explicitly listing ** observations through that period. If there aren't any ** near the end of the 400-year period, add a redundant -- 2.40.1
participants (1)
-
Paul Eggert