
* date.1: Update the example to next year. Remove duplication of spec with strftime, as this is too much of a pain to maintain separately for what is just a demo; but give an example for clarity. Update list of files accessed, to match current code. --- date.1 | 110 +++++++++------------------------------------------------ 1 file changed, 16 insertions(+), 94 deletions(-) diff --git a/date.1 b/date.1 index 01907bc7..9b025bc9 100644 --- a/date.1 +++ b/date.1 @@ -35,7 +35,7 @@ command without arguments writes the date and time to the standard output in the form .ce 1 -Wed Mar 8 14:54:40 EST 1989 +Sat Mar 8 14:54:40 EST 2025 .br with .B EST @@ -49,92 +49,17 @@ If a command-line argument starts with a plus sign (\c .q "\fB+\fP" ), the rest of the argument is used as a .I format -that controls what appears in the output. -In the format, when a percent sign (\c -.q "\fB%\fP" -appears, -it and the character after it are not output, -but rather identify part of the date or time -to be output in a particular way -(or identify a special character to output): -.nf -.sp -.if t .in +.5i -.if n .in +2 -.ta \w'%M\0\0'u +\w'Wed Mar 8 14:54:40 EST 1989\0\0'u - Sample output Explanation -%a Wed Abbreviated weekday name* -%A Wednesday Full weekday name* -%b Mar Abbreviated month name* -%B March Full month name* -%c Wed Mar 08 14:54:40 1989 Date and time* -%C 19 Century -%d 08 Day of month (always two digits) -%D 03/08/89 Month/day/year (eight characters) -%e 8 Day of month (leading zero blanked) -%h Mar Abbreviated month name* -%H 14 24-hour-clock hour (two digits) -%I 02 12-hour-clock hour (two digits) -%j 067 Julian day number (three digits) -%k 2 12-hour-clock hour (leading zero blanked) -%l 14 24-hour-clock hour (leading zero blanked) -%m 03 Month number (two digits) -%M 54 Minute (two digits) -%n \\n newline character -%p PM AM/PM designation -%r 02:54:40 PM Hour:minute:second AM/PM designation -%R 14:54 Hour:minute -%S 40 Second (two digits) -%t \\t tab character -%T 14:54:40 Hour:minute:second -%U 10 Sunday-based week number (two digits) -%w 3 Day number (one digit, Sunday is 0) -%W 10 Monday-based week number (two digits) -%x 03/08/89 Date* -%X 14:54:40 Time* -%y 89 Last two digits of year -%Y 1989 Year in full -%z -0500 Numeric time zone -%Z EST Time zone abbreviation -%+ Wed Mar 8 14:54:40 EST 1989 Default output format* -.if t .in -.5i -.if n .in -2 -* The exact output depends on the locale. -.sp -.fi -If a character other than one of those shown above appears after -a percent sign in the format, -that following character is output. -All other characters in the format are copied unchanged to the output; -a newline character is always added at the end of the output. -.PP -In Sunday-based week numbering, -the first Sunday of the year begins week 1; -days preceding it are part of -.q "week 0" . -In Monday-based week numbering, -the first Monday of the year begins week 1. -.PP -To set the date, use a command line argument with one of the following forms: -.nf -.if t .in +.5i -.if n .in +2 -.ta \w'198903081454\0'u -1454 24-hour-clock hours (first two digits) and minutes -081454 Month day (first two digits), hours, and minutes -03081454 Month (two digits, January is 01), month day, hours, minutes -8903081454 Year, month, month day, hours, minutes -0308145489 Month, month day, hours, minutes, year - (on System V-compatible systems) -030814541989 Month, month day, hours, minutes, four-digit year -198903081454 Four-digit year, month, month day, hours, minutes -.if t .in -.5i -.if n .in -2 -.fi -If the century, year, month, or month day is not given, -the current value is used. -Any of the above forms may be followed by a period and two digits that give -the seconds part of the new time; if no seconds are given, zero is assumed. +that is processed by +.BR strftime (3) +to determine what to output; +a newline character is appended. +For example, the shell command: +.ce 1 +date +"%Y\*-%m\*-%d %H:%M:%S %z" +.br +outputs a line like +.q "2025\*-03\*-08 14:54:40 \*-0500" +instead. .PP These options are available: .TP @@ -149,16 +74,13 @@ past the epoch of 1970-01-01 00:00:00 UTC, where should be an integer, either decimal, octal (leading 0), or hexadecimal (leading 0x), preceded by an optional sign. .SH FILES -.ta \w'/usr/share/zoneinfo/posixrules\0\0'u +.ta \w'/usr/share/zoneinfo/Etc/UTC\0\0'u /etc/localtime local timezone file .br /usr/lib/locale/\f2L\fP/LC_TIME description of time locale \f2L\fP .br /usr/share/zoneinfo timezone directory .br -/usr/share/zoneinfo/posixrules default DST rules (obsolete) -.br -/usr/share/zoneinfo/GMT for UTC leap seconds -.PP -If /usr/share/zoneinfo/GMT is absent, -UTC leap seconds are loaded from /usr/share/zoneinfo/GMT0 if present. +/usr/share/zoneinfo/Etc/UTC for UTC leap seconds +.SH SEE ALSO +.BR strftime (3). -- 2.47.1

* newstrftime.3: Warn more about two-digit years. --- newstrftime.3 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/newstrftime.3 b/newstrftime.3 index 21aef9d0..e8200095 100644 --- a/newstrftime.3 +++ b/newstrftime.3 @@ -144,6 +144,9 @@ is replaced by the locale's appropriate date and time representation. %D is equivalent to .c %m/%d/%y . +Although used in the United States for current dates, +this format is ambiguous elsewhere +and for dates that might involve other centuries. .RI [ tm_year , .IR tm_mon , .IR tm_mday ] @@ -167,6 +170,8 @@ is equivalent to .TP %G is replaced by the ISO 8601 year with century as a decimal number. +This is the year that includes the greater part of the week. +(Monday as the first day of a week). See also the .c %V conversion specification. @@ -176,11 +181,7 @@ conversion specification. .TP %g is replaced by the ISO 8601 year without century as a decimal number [00,99]. -This is the year that includes the greater part of the week. -(Monday as the first day of a week). -See also the -.c %V -conversion specification. +Since it omits the century, it is ambiguous for dates. .RI [ tm_year , .IR tm_yday , .IR tm_wday ] @@ -345,6 +346,8 @@ is replaced by the locale's appropriate time representation. .TP %x is replaced by the locale's appropriate date representation. +This format can be ambiguous for dates, e.g., +it can generate "01/02/03" in the C locale. .RI [ tm_year , .IR tm_yday , .IR tm_mon , @@ -363,6 +366,7 @@ is replaced by the year with century as a decimal number. .TP %y is replaced by the year without century as a decimal number [00,99]. +Since it omits the century, it is ambiguous for dates. .RI [ tm_year ] .TP %Z -- 2.47.1

The \*- portability hassle in man pages is no longer needed, now that groff puts into a PDF file something that cuts and pastes as ASCII minus. Removing this hack simplifies the man pages and is nicer for some man page processors. --- date.1 | 16 +++--- newctime.3 | 4 +- newstrftime.3 | 44 ++++++++-------- newtzset.3 | 24 ++++----- time2posix.3 | 4 +- tzfile.5 | 22 ++++---- tzselect.8 | 26 +++++----- zdump.8 | 36 +++++++------ zic.8 | 136 ++++++++++++++++++++++++-------------------------- 9 files changed, 145 insertions(+), 167 deletions(-) diff --git a/date.1 b/date.1 index 9b025bc9..3a02e7c2 100644 --- a/date.1 +++ b/date.1 @@ -6,15 +6,13 @@ date \- show and set date and time .SH SYNOPSIS .if n .nh .if n .na -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .B date [ -.B \*-u +.B \-u ] [ -.B \*-c +.B \-c ] [ -.B \*-r +.B \-r .I seconds ] [ .BI + format @@ -55,18 +53,18 @@ to determine what to output; a newline character is appended. For example, the shell command: .ce 1 -date +"%Y\*-%m\*-%d %H:%M:%S %z" +date +"%Y\-%m\-%d %H:%M:%S %z" .br outputs a line like -.q "2025\*-03\*-08 14:54:40 \*-0500" +.q "2025\-03\-08 14:54:40 \-0500" instead. .PP These options are available: .TP -.BR \*-u " or " \*-c +.BR \-u " or " \-c Use Universal Time when setting and showing the date and time. .TP -.BI "\*-r " seconds +.BI "\-r " seconds Output the date that corresponds to .I seconds past the epoch of 1970-01-01 00:00:00 UTC, where diff --git a/newctime.3 b/newctime.3 index d19fd25b..5e1b6148 100644 --- a/newctime.3 +++ b/newctime.3 @@ -5,8 +5,6 @@ asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time .SH SYNOPSIS .nf -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .B #include <time.h> .PP .B [[deprecated]] char *ctime(time_t const *clock); @@ -41,7 +39,7 @@ asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time .B "time_t mktime_z(timezone_t restrict zone," .B " struct tm *restrict tm);" .PP -.B cc ... \*-ltz +.B cc ... \-ltz .fi .SH DESCRIPTION .ie '\(en'' .ds en \- diff --git a/newstrftime.3 b/newstrftime.3 index e8200095..e9a38224 100644 --- a/newstrftime.3 +++ b/newstrftime.3 @@ -40,8 +40,6 @@ strftime \- format date and time .SH SYNOPSIS .nf -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .B #include <time.h> .PP .B "size_t strftime(char *restrict buf, size_t maxsize," @@ -93,7 +91,7 @@ If a bracketed member name is followed by .B strftime can use the named member even though POSIX.1-2024 does not list it; if the name is followed by -.q \*- , +.q \- , .B strftime ignores the member even though POSIX.1-2024 lists it which means portable code should set it. @@ -139,7 +137,7 @@ is replaced by the locale's appropriate date and time representation. .IR tm_sec , .IR tm_gmtoff , .IR tm_zone , -.IR tm_isdst \*-]. +.IR tm_isdst \-]. .TP %D is equivalent to @@ -281,7 +279,7 @@ with "%s". .IR tm_min , .IR tm_sec , .IR tm_gmtoff +, -.IR tm_isdst \*-]. +.IR tm_isdst \-]. .TP %T is replaced by the time in the format @@ -298,7 +296,7 @@ is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. .RI [ tm_wday , .IR tm_yday , -.IR tm_year \*-] +.IR tm_year \-] .TP %u is replaced by the weekday (Monday as the first day of the week) @@ -332,17 +330,17 @@ as a decimal number [0,6]. .TP %X is replaced by the locale's appropriate time representation. -.RI [ tm_year \*-, -.IR tm_yday \*-, -.IR tm_mon \*-, -.IR tm_mday \*-, -.IR tm_wday \*-, +.RI [ tm_year \-, +.IR tm_yday \-, +.IR tm_mon \-, +.IR tm_mday \-, +.IR tm_wday \-, .IR tm_hour , .IR tm_min , .IR tm_sec , .IR tm_gmtoff , .IR tm_zone , -.IR tm_isdst \*-]. +.IR tm_isdst \-]. .TP %x is replaced by the locale's appropriate date representation. @@ -353,12 +351,12 @@ it can generate "01/02/03" in the C locale. .IR tm_mon , .IR tm_mday , .IR tm_wday , -.IR tm_hour \*-, -.IR tm_min \*-, -.IR tm_sec \*-, -.IR tm_gmtoff \*-, -.IR tm_zone \*-, -.IR tm_isdst \*-]. +.IR tm_hour \-, +.IR tm_min \-, +.IR tm_sec \-, +.IR tm_gmtoff \-, +.IR tm_zone \-, +.IR tm_isdst \-]. .TP %Y is replaced by the year with century as a decimal number. @@ -373,22 +371,22 @@ Since it omits the century, it is ambiguous for dates. is replaced by the time zone abbreviation, or by the empty string if this is not determinable. .RI [ tm_zone , -.IR tm_isdst \*-] +.IR tm_isdst \-] .TP %z is replaced by the offset from the Prime Meridian -in the format +HHMM or \*-HHMM (ISO 8601) as appropriate, +in the format +HHMM or \-HHMM (ISO 8601) as appropriate, with positive values representing locations east of Greenwich, or by the empty string if this is not determinable. -The numeric time zone abbreviation \*-0000 is used when the time is +The numeric time zone abbreviation \-0000 is used when the time is Universal Time but local time is indeterminate; by convention this is used for locations while uninhabited, and corresponds to a zero offset when the time zone abbreviation begins with -.q "\*-" . +.q "\-" . .RI [ tm_gmtoff , .IR tm_zone +, -.IR tm_isdst \*-] +.IR tm_isdst \-] .TP %% is replaced by a single %. diff --git a/newtzset.3 b/newtzset.3 index 661fb25b..db6bfa7f 100644 --- a/newtzset.3 +++ b/newtzset.3 @@ -5,8 +5,6 @@ tzset \- initialize time conversion information .SH SYNOPSIS .nf -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .B #include <time.h> .PP .BI "timezone_t tzalloc(char const *" TZ ); @@ -23,7 +21,7 @@ tzset \- initialize time conversion information .br .B extern int daylight; .PP -.B cc ... \*-ltz +.B cc ... \-ltz .fi .SH DESCRIPTION .ie '\(en'' .ds en \- @@ -110,7 +108,7 @@ except a leading colon digits, comma .RB ( , ), ASCII minus -.RB ( \*- ), +.RB ( \- ), ASCII plus .RB ( + ), and NUL bytes are allowed. @@ -150,7 +148,7 @@ daylight saving time is assumed to be one hour ahead of standard time. One or more digits may be used; the value is always interpreted as a decimal number. The hour must be between zero and 24, and the minutes (and seconds) \*(en if present \*(en between zero and 59. If preceded by a -.q "\*-" , +.q "\-" , the time zone shall be east of the Prime Meridian; otherwise it shall be west (which may be indicated by an optional preceding .q "+" . @@ -239,7 +237,7 @@ values that directly specify the timezone. stands for US Eastern Standard Time (EST), 5 hours behind UT, without daylight saving. .TP -.B <+12>\*-12<+13>,M11.1.0,M1.2.1/147 +.B <+12>\-12<+13>,M11.1.0,M1.2.1/147 stands for Fiji time, 12 hours ahead of UT, springing forward on November's first Sunday at 02:00, and falling back on January's second Monday at 147:00 (i.e., 03:00 on the @@ -249,34 +247,34 @@ and daylight saving time are and .q "+13". .TP -.B IST\*-2IDT,M3.4.4/26,M10.5.0 +.B IST\-2IDT,M3.4.4/26,M10.5.0 stands for Israel Standard Time (IST) and Israel Daylight Time (IDT), 2 hours ahead of UT, springing forward on March's fourth Thursday at 26:00 (i.e., 02:00 on the first Friday on or after March 23), and falling back on October's last Sunday at 02:00. .TP -.B <\*-04>4<\*-03>,J1/0,J365/25 +.B <\-04>4<\-03>,J1/0,J365/25 stands for permanent daylight saving time, 3 hours behind UT with abbreviation -.q "\*-03". +.q "\-03". There is a dummy fall-back transition on December 31 at 25:00 daylight saving time (i.e., 24:00 standard time, equivalent to January 1 at 00:00 standard time), and a simultaneous spring-forward transition on January 1 at 00:00 standard time, so daylight saving time is in effect all year and the initial -.B <\*-04> +.B <\-04> is a placeholder. .TP -.B <\*-03>3<\*-02>,M3.5.0/\*-2,M10.5.0/\*-1 +.B <\-03>3<\-02>,M3.5.0/\-2,M10.5.0/\-1 stands for time in western Greenland, 3 hours behind UT, where clocks follow the EU rules of springing forward on March's last Sunday at 01:00 UT (\-02:00 local time, i.e., 22:00 the previous day) and falling back on October's last Sunday at 01:00 UT (\-01:00 local time, i.e., 23:00 the previous day). The abbreviations for standard and daylight saving time are -.q "\*-03" +.q "\-03" and -.q "\*-02". +.q "\-02". .PP If .I TZ diff --git a/time2posix.3 b/time2posix.3 index 6644060a..4a6969ed 100644 --- a/time2posix.3 +++ b/time2posix.3 @@ -5,15 +5,13 @@ time2posix, posix2time \- convert seconds since the Epoch .SH SYNOPSIS .nf -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .B #include <time.h> .PP .B time_t time2posix(time_t t); .PP .B time_t posix2time(time_t t); .PP -.B cc ... \*-ltz +.B cc ... \-ltz .fi .SH DESCRIPTION .ie '\(en'' .ds en \- diff --git a/tzfile.5 b/tzfile.5 index 34b994cc..a021859d 100644 --- a/tzfile.5 +++ b/tzfile.5 @@ -11,8 +11,6 @@ tzfile \- timezone information .de q \\$3\*(lq\\$1\*(rq\\$2 .. -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- The timezone information files used by .BR tzset (3) are typically found under a directory with a name like @@ -123,7 +121,7 @@ and serves as an index into the array of time zone abbreviation bytes that follow the .B ttinfo -entries in the file; if the designated string is "\*-00", the +entries in the file; if the designated string is "\-00", the .B ttinfo entry is a placeholder indicating that local time is unspecified. The @@ -188,7 +186,7 @@ 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 proleptic TZ string that lacks rules. -For example, when TZ="EET\*-2EEST" and there is no TZif file "EET\*-2EEST", +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. @@ -197,7 +195,7 @@ 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 +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 @@ -238,7 +236,7 @@ the earliest transition time. For version-3-format timezone files, a TZ string (see .BR newtzset (3)) may use the following POSIX.1-2024 extensions to POSIX.1-2017: -First, as in TZ="<\*-02>2<\*-01>,M3.5.0/\*-1,M10.5.0/0", +First, as in TZ="<\-02>2<\-01>,M3.5.0/\-1,M10.5.0/0", the hours part of its transition times may be signed and range from \-167 through 167 instead of being limited to unsigned values from 0 through 24. @@ -294,7 +292,7 @@ time did not exist (possibly with an error indication). 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 @@ -396,7 +394,7 @@ and even for current timestamps it can fail for settings like TZ="Africa/Casablanca". This corresponds to a TZif file containing explicit transitions through the year 2087, followed by a footer containing the TZ string -.q <+01>\*-1 , +.q <+01>\-1 , which should be used only for timestamps after the last explicit transition. .IP \(bu @@ -438,7 +436,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. @@ -448,7 +446,7 @@ 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 TZ string -.q "IST\*-1GMT0,M10.5.0,M3.5.0/1", +.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 @@ -485,10 +483,10 @@ Readers that do not support negative timestamps are likely to be more prone to this problem. .IP \(bu Some readers mishandle time zone abbreviations like -.q "\*-08" +.q "\-08" that contain .q "+", -.q "\*-", +.q "\-", or digits. .IP \(bu Some readers mishandle UT offsets that are out of the diff --git a/tzselect.8 b/tzselect.8 index ee031614..b83f702d 100644 --- a/tzselect.8 +++ b/tzselect.8 @@ -4,8 +4,6 @@ .SH NAME tzselect \- select a timezone .SH SYNOPSIS -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- .ds d " degrees .ds m " minutes .ds s " seconds @@ -20,15 +18,15 @@ tzselect \- select a timezone .\} .B tzselect [ -.B \*-c +.B \-c .I coord ] [ -.B \*-n +.B \-n .I limit ] [ -.B \*-\*-help +.B \-\-help ] [ -.B \*-\*-version +.B \-\-version ] .SH DESCRIPTION The @@ -40,7 +38,7 @@ The output is suitable as a value for the TZ environment variable. All interaction with the user is done via standard input and standard error. .SH OPTIONS .TP -.BI "\*-c " coord +.BI "\-c " coord Instead of asking for continent and then country and then city, ask for selection from time zones whose largest cities are closest to the location with geographical coordinates @@ -70,27 +68,27 @@ seconds, with any trailing fractions represent fractional minutes or .I SS is present) seconds. The decimal point is that of the current locale. For example, in the (default) C locale, -.B "\*-c\ +40.689\*-074.045" +.B "\-c\ +40.689\-074.045" specifies 40.689\*d\*_N, 74.045\*d\*_W, -.B "\*-c\ +4041.4\*-07402.7" +.B "\-c\ +4041.4\-07402.7" specifies 40\*d\*_41.4\*m\*_N, 74\*d\*_2.7\*m\*_W, and -.B "\*-c\ +404121\*-0740240" +.B "\-c\ +404121\-0740240" specifies 40\*d\*_41\*m\*_21\*s\*_N, 74\*d\*_2\*m\*_40\*s\*_W. If .I coord is not one of the documented forms, the resulting behavior is unspecified. .TP -.BI "\*-n " limit +.BI "\-n " limit When -.B \*-c +.B \-c is used, display the closest .I limit locations (default 10). .TP -.B "\*-\*-help" +.B "\-\-help" Output help information and exit. .TP -.B "\*-\*-version" +.B "\-\-version" Output version information and exit. .SH "ENVIRONMENT VARIABLES" .TP diff --git a/zdump.8 b/zdump.8 index 8792b54e..9996039e 100644 --- a/zdump.8 +++ b/zdump.8 @@ -18,8 +18,6 @@ zdump \- timezone dumper .de q \\$3\*(lq\\$1\*(rq\\$2 .. -.ie \n(.g .ds - \f(CR-\fP -.el .ds - \- The .B zdump program prints the current time in each @@ -28,19 +26,19 @@ named on the command line. A .I timezone of -.B \*- +.B \- is treated as if it were /dev/stdin; this can be used to pipe TZif data into .BR zdump . .SH OPTIONS .TP -.B \*-\*-version +.B \-\-version Output version information and exit. .TP -.B \*-\*-help +.B \-\-help Output short usage message and exit. .TP -.B \*-i +.B \-i Output a description of time intervals. For each .I timezone on the command line, output an interval-format description of the @@ -48,7 +46,7 @@ timezone. See .q "INTERVAL FORMAT" below. .TP -.B \*-v +.B \-v Output a verbose description of time intervals. For each .I timezone @@ -74,26 +72,26 @@ if the given local time is known to be .I N seconds east of Greenwich. .TP -.B \*-V +.B \-V Like -.BR \*-v , +.BR \-v , except omit output concerning extreme time and year values. This generates output that is easier to compare to that of implementations with different time representations. .TP -.BI "\*-c " \fR[\fIloyear , \fR]\fIhiyear +.BI "\-c " \fR[\fIloyear , \fR]\fIhiyear Cut off interval output at the given year(s). Cutoff times are computed using the proleptic Gregorian calendar with year 0 and with Universal Time (UT) ignoring leap seconds. Cutoffs are at the start of each year, where the lower-bound timestamp is inclusive and the upper is exclusive; for example, -.B "\*-c 1970,2070" +.B "\-c 1970,2070" selects transitions on or after 1970-01-01 00:00:00 UTC and before 2070-01-01 00:00:00 UTC. The default cutoff is -.BR \*-500,2500 . +.BR \-500,2500 . .TP -.BI "\*-t " \fR[\fIlotime , \fR]\fIhitime +.BI "\-t " \fR[\fIlotime , \fR]\fIhitime Cut off interval output at the given time(s), given in decimal seconds since 1970-01-01 00:00:00 Coordinated Universal Time (UTC). @@ -101,7 +99,7 @@ The .I timezone determines whether the count includes leap seconds. As with -.BR \*-c , +.BR \-c , the cutoff's lower bound is inclusive and its upper bound is exclusive. .SH "INTERVAL FORMAT" The interval format is a compact text representation that is intended @@ -111,7 +109,7 @@ then a line where .I string is a double-quoted string giving the timezone, a second line -.q "\*- \*- \fIinterval\fP" +.q "\- \- \fIinterval\fP" describing the time interval before the first transition if any, and zero or more following lines .q "\fIdate time interval\fP", @@ -137,11 +135,11 @@ daylight saving time and negative for unknown. In times and in UT offsets with absolute value less than 100 hours, the seconds are omitted if they are zero, and the minutes are also omitted if they are also zero. Positive UT -offsets are east of Greenwich. The UT offset \*-00 denotes a UT +offsets are east of Greenwich. The UT offset \-00 denotes a UT placeholder in areas where the actual offset is unspecified; by convention, this occurs when the UT offset is zero and the time zone abbreviation begins with -.q "\*-" +.q "\-" or is .q "zzz". .PP @@ -218,9 +216,9 @@ This works in all real-world cases; one can construct artificial time zones for which this fails. .PP In the -.B \*-v +.B \-v and -.B \*-V +.B \-V output, .q "UT" denotes the value returned by diff --git a/zic.8 b/zic.8 index 50298a09..4eeb7a46 100644 --- a/zic.8 +++ b/zic.8 @@ -22,14 +22,8 @@ zic \- timezone compiler .el .ds < \(la .ie '\(ra'' .ds > > .el .ds > \(ra -.ie \n(.g \{\ -. ds : \: -. ds - \f(CR-\fP -.\} -.el \{\ -. ds : -. ds - \- -.\} +.ie \n(.g .ds : \: +.el .ds : . .ds d " degrees .ds m " minutes .ds s " seconds @@ -50,17 +44,17 @@ specified in this input. If a .I filename is -.q "\*-" , +.q "\-" , standard input is read. .SH OPTIONS .TP -.B "\*-\*-version" +.B "\-\-version" Output version information and exit. .TP -.B \*-\*-help +.B \-\-help Output short usage message and exit. .TP -.BI "\*-b " bloat +.BI "\-b " bloat Output backward-compatibility data as specified by .IR bloat . If @@ -81,14 +75,14 @@ The default is as software that mishandles 64-bit data typically mishandles timestamps after the year 2038 anyway. Also see the -.B \*-r +.B \-r option for another way to alter output size. .TP -.BI "\*-d " directory +.BI "\-d " directory Create time conversion information files in the named directory rather than in the standard directory named below. .TP -.BI "\*-l " timezone +.BI "\-l " timezone Use .I timezone as local time. @@ -102,19 +96,19 @@ Link \fItimezone\fP localtime If .I timezone is -.BR \*- , +.BR \- , any already-existing link is removed. .TP -.BI "\*-L " leapsecondfilename +.BI "\-L " leapsecondfilename Read leap second information from the file with the given name. If this option is not used, no leap second information appears in output files. .TP -.BI "\*-p " timezone +.BI "\-p " timezone Use .IR timezone 's rules when handling nonstandard -TZ strings like "EET\*-2EEST" that lack transition rules. +TZ strings like "EET\-2EEST" that lack transition rules. .B zic will act as if the input contained a link line of the form .sp @@ -124,21 +118,21 @@ Link \fItimezone\fP posixrules If .I timezone is -.q "\*-" +.q "\-" (the default), any already-existing link is removed. .sp Unless .I timezone is -.q "\*-" , +.q "\-" , this option is obsolete and poorly supported. Among other things it should not be used for timestamps after the year 2037, and it should not be combined with -.B "\*-b slim" +.B "\-b slim" if .IR timezone 's transitions are at standard time or Universal Time (UT) instead of local time. .TP -.BR "\*-r " "[\fB@\fP\fIlo\fP][\fB/@\fP\fIhi\fP]" +.BR "\-r " "[\fB@\fP\fIlo\fP][\fB/@\fP\fIhi\fP]" Limit the applicability of output files to timestamps in the range from .I lo @@ -152,17 +146,17 @@ are possibly signed decimal counts of seconds since the Epoch (1970-01-01 00:00:00 UTC). Omitted counts default to extreme values. The output files use UT offset 0 and abbreviation -.q "\*-00" +.q "\-00" in place of the omitted timestamp data. For example, -.q "zic \*-r @0" +.q "zic \-r @0" omits data intended for negative timestamps (i.e., before the Epoch), and -.q "zic \*-r @0/@2147483648" +.q "zic \-r @0/@2147483648" outputs data intended only for nonnegative timestamps that fit into 31-bit signed integers. On platforms with GNU .BR date , -.q "zic \*-r @$(date +%s)" +.q "zic \-r @$(date +%s)" omits data intended for past timestamps. Although this option typically reduces the output file's size, the size can increase due to the need to represent the timestamp range @@ -173,10 +167,10 @@ causes a TZif file to contain explicit entries for transitions rather than concisely representing them with a proleptic TZ string. Also see the -.B "\*-b slim" +.B "\-b slim" option for another way to shrink output size. .TP -.BI "\*-R @" hi +.BI "\-R @" hi Generate redundant trailing explicit transitions for timestamps that occur less than .I hi @@ -187,11 +181,11 @@ Although it accommodates nonstandard TZif readers that ignore the proleptic TZ string, it increases the size of the altered output files. .TP -.BI "\*-t " file +.BI "\-t " file When creating local time information, put the configuration link in the named file rather than in the standard location. .TP -.B \*-v +.B \-v Be more verbose, and complain about the following situations: .RS .PP @@ -259,10 +253,10 @@ before 1970 or after the start of 2038. The output contains a truncated leap second table, which can cause some older TZif readers to misbehave. This can occur if the -.B "\*-L" +.B "\-L" option is used, and either an Expires line is present or the -.B "\*-r" +.B "\-r" option is also used. .PP The output file contains more than 1200 transitions, @@ -276,13 +270,13 @@ POSIX requires at least 3, and requires implementations to support at least 6. .PP An output file name contains a byte that is not an ASCII letter, -.q "\*-" , +.q "\-" , .q "/" , or .q "_" ; or it contains a file name component that contains more than 14 bytes or that starts with -.q "\*-" . +.q "\-" . .RE .SH FILES Input files use the format described in this section; output files use @@ -301,7 +295,7 @@ non-PPCS bytes. Non-PPCS characters typically occur only in comments: although output file names and time zone abbreviations can contain nearly any character, other software will work better if these are limited to the restricted syntax described under the -.B \*-v +.B \-v option. .PP Input lines are made up of fields. @@ -331,14 +325,14 @@ abbreviation must be unambiguous in context. A rule line has the form .nf .ti +2 -.ta \w'Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'\*-\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00w\0\0'u +\w'1:00d\0\0'u +.ta \w'Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'\-\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00w\0\0'u +\w'1:00d\0\0'u .sp -Rule NAME FROM TO \*- IN ON AT SAVE LETTER/S +Rule NAME FROM TO \- IN ON AT SAVE LETTER/S .sp For example: .ti +2 .sp -Rule US 1967 1973 \*- Apr lastSun 2:00w 1:00d D +Rule US 1967 1973 \- Apr lastSun 2:00w 1:00d D .sp .fi The fields that make up a rule line are: @@ -347,7 +341,7 @@ The fields that make up a rule line are: Gives the name of the rule set that contains this line. The name must start with a character that is neither an ASCII digit nor -.q \*- +.q \- nor .q + . To allow for future extensions, @@ -375,9 +369,9 @@ may be used to repeat the value of the .B FROM field. .TP -.B \*- +.B \- Is a reserved field and should always contain -.q \*- +.q \- for compatibility with older versions of .BR zic . It was previously known as the @@ -455,8 +449,8 @@ Recognized forms include: 15:00 3 PM, 15 hours after 00:00 24:00 end of day, 24 hours after 00:00 260:00 260 hours after 00:00 -\*-2:30 2.5 hours before 00:00 -\*- equivalent to 0 +\-2:30 2.5 hours before 00:00 +\- equivalent to 0 .fi .in .sp @@ -530,7 +524,7 @@ or .q "EDT" ) of time zone abbreviations to be used when this rule is in effect. If this field is -.q \*- , +.q \- , the variable part is null. .PP A zone line has the form @@ -577,7 +571,7 @@ field, giving the amount of time to be added to local standard time and whether the resulting time is standard or daylight saving. Standard time applies if this field is -.B \*- +.B \- or for timestamps occurring before any rule takes effect. When an amount of time is given, only the sum of standard time and this amount matters. @@ -613,9 +607,9 @@ To conform to POSIX, a time zone abbreviation should contain only alphanumeric ASCII characters, .q "+" and -.q "\*-". +.q "\-". By convention, the time zone abbreviation -.q "\*-00" +.q "\-00" is a placeholder that means local time is unspecified. .TP .B UNTIL @@ -674,25 +668,25 @@ For example: .ne 7 .nf .in +2 -.ta \w'# Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'2006\0\0'u +\w'\*-\0\0'u +\w'Oct\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u +.ta \w'# Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'2006\0\0'u +\w'\-\0\0'u +\w'Oct\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u .sp -# Rule NAME FROM TO \*- IN ON AT SAVE LETTER/S +# Rule NAME FROM TO \- IN ON AT SAVE LETTER/S Rule US 1967 2006 - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D .ta \w'# Zone\0\0'u +\w'America/Menominee\0\0'u +\w'STDOFF\0\0'u +\w'RULES\0\0'u +\w'FORMAT\0\0'u # Zone NAME STDOFF RULES FORMAT [UNTIL] -Zone America/Menominee \*-5:00 \*- EST 1973 Apr 29 2:00 - \*-6:00 US C%sT +Zone America/Menominee \-5:00 \- EST 1973 Apr 29 2:00 + \-6:00 US C%sT .sp .in .fi Here, an incorrect reading would be there were two clock changes on 1973-04-29, -the first from 02:00 EST (\*-05) to 01:00 CST (\*-06), -and the second an hour later from 02:00 CST (\*-06) to 03:00 CDT (\*-05). +the first from 02:00 EST (\-05) to 01:00 CST (\-06), +and the second an hour later from 02:00 CST (\-06) to 03:00 CDT (\-05). However, .B zic -interprets this more sensibly as a single transition from 02:00 CST (\*-05) to -02:00 CDT (\*-05). +interprets this more sensibly as a single transition from 02:00 CST (\-05) to +02:00 CDT (\-05). .PP A link line has the form .sp @@ -731,7 +725,7 @@ For example: .ta \w'Zone\0\0'u +\w'Greenwich\0\0'u Link Greenwich G_M_T Link Etc/GMT Greenwich -Zone Etc/GMT\0\00\0\0\*-\0\0GMT +Zone Etc/GMT\0\00\0\0\-\0\0GMT .sp .in .fi @@ -772,7 +766,7 @@ should be .q "+" if a second was added or -.q "\*-" +.q "\-" if a second was skipped. The .B R/S @@ -796,7 +790,7 @@ rolling leap seconds can be useful in specialized applications like SMPTE timecodes that may prefer to put leap second discontinuities at the end of a local broadcast day. However, rolling leap seconds are not supported if the -.B \*-r +.B \-r option is used. .PP The expiration line, if present, has the form: @@ -827,23 +821,23 @@ Here is an extended example of input, intended to illustrate many of its features. .nf .in +2 -.ta \w'# Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'\*-\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u +.ta \w'# Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'\-\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u .sp -# Rule NAME FROM TO \*- IN ON AT SAVE LETTER/S -Rule Swiss 1941 1942 \*- May Mon>=1 1:00 1:00 S -Rule Swiss 1941 1942 \*- Oct Mon>=1 2:00 0 \*- +# Rule NAME FROM TO \- IN ON AT SAVE LETTER/S +Rule Swiss 1941 1942 \- May Mon>=1 1:00 1:00 S +Rule Swiss 1941 1942 \- Oct Mon>=1 2:00 0 \- .sp .5 -Rule EU 1977 1980 \*- Apr Sun>=1 1:00u 1:00 S -Rule EU 1977 only \*- Sep lastSun 1:00u 0 \*- -Rule EU 1978 only \*- Oct 1 1:00u 0 \*- -Rule EU 1979 1995 \*- Sep lastSun 1:00u 0 \*- -Rule EU 1981 max \*- Mar lastSun 1:00u 1:00 S -Rule EU 1996 max \*- Oct lastSun 1:00u 0 \*- +Rule EU 1977 1980 \- Apr Sun>=1 1:00u 1:00 S +Rule EU 1977 only \- Sep lastSun 1:00u 0 \- +Rule EU 1978 only \- Oct 1 1:00u 0 \- +Rule EU 1979 1995 \- Sep lastSun 1:00u 0 \- +Rule EU 1981 max \- Mar lastSun 1:00u 1:00 S +Rule EU 1996 max \- Oct lastSun 1:00u 0 \- .sp .ta \w'# Zone\0\0'u +\w'Europe/Zurich\0\0'u +\w'0:29:45.50\0\0'u +\w'RULES\0\0'u +\w'FORMAT\0\0'u # Zone NAME STDOFF RULES FORMAT [UNTIL] -Zone Europe/Zurich 0:34:08 \*- LMT 1853 Jul 16 - 0:29:45.50 \*- BMT 1894 Jun +Zone Europe/Zurich 0:34:08 \- LMT 1853 Jul 16 + 0:29:45.50 \- BMT 1894 Jun 1:00 Swiss CE%sT 1981 1:00 EU CE%sT .sp -- 2.47.1

* newctime.3: Reorder so that functions are described in a more sensible order, e.g., asctime is explained first and ctime merely defers to it. Also put asctime and ctime later since they are deprecated. Mention that localtime and gmtime return a null pointer on failure. --- newctime.3 | 148 +++++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 77 deletions(-) diff --git a/newctime.3 b/newctime.3 index 5e1b6148..9d09e5a5 100644 --- a/newctime.3 +++ b/newctime.3 @@ -7,38 +7,31 @@ asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time .nf .B #include <time.h> .PP -.B [[deprecated]] char *ctime(time_t const *clock); -.PP -/* Only in POSIX.1-2017 and earlier. */ -.B char *ctime_r(time_t const *clock, char *buf); -.PP -.B double difftime(time_t time1, time_t time0); -.PP -.B [[deprecated]] char *asctime(struct tm const *tm); -.PP -/* Only in POSIX.1-2017 and earlier. */ -.B "char *asctime_r(struct tm const *restrict tm," -.B " char *restrict result);" -.PP .B struct tm *localtime(time_t const *clock); -.PP .B "struct tm *localtime_r(time_t const *restrict clock," .B " struct tm *restrict result);" -.PP .B "struct tm *localtime_rz(timezone_t restrict zone," .B " time_t const *restrict clock," .B " struct tm *restrict result);" .PP .B struct tm *gmtime(time_t const *clock); -.PP .B "struct tm *gmtime_r(time_t const *restrict clock," .B " struct tm *restrict result);" .PP .B time_t mktime(struct tm *tm); -.PP .B "time_t mktime_z(timezone_t restrict zone," .B " struct tm *restrict tm);" .PP +.B double difftime(time_t time1, time_t time0); +.PP +.B [[deprecated]] char *asctime(struct tm const *tm); +.B [[deprecated]] char *ctime(time_t const *clock); +.PP +/* Only in POSIX.1-2017 and earlier. */ +.B char *ctime_r(time_t const *clock, char *buf); +.B "char *asctime_r(struct tm const *restrict tm," +.B " char *restrict result);" +.PP .B cc ... \-ltz .fi .SH DESCRIPTION @@ -52,82 +45,37 @@ asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time \\$3\*(lq\\$1\*(rq\\$2 .. The -.B ctime -function -converts a long integer, pointed to by -.IR clock , -and returns a pointer to a -string of the form -.br -.ce -.eo -Thu Nov 24 18:22:48 1986\n\0 -.br -.ec -Years requiring fewer than four characters are padded with leading zeroes. -For years longer than four characters, the string is of the form -.br -.ce -.eo -Thu Nov 24 18:22:48 81986\n\0 -.ec -.br -with five spaces before the year. -These unusual formats are designed to make it less likely that older -software that expects exactly 26 bytes of output will mistakenly output -misleading values for out-of-range years. -.PP -The -.BI * clock -timestamp represents the time in seconds since 1970-01-01 00:00:00 -Coordinated Universal Time (UTC). -The POSIX standard says that timestamps must be nonnegative -and must ignore leap seconds. -Many implementations extend POSIX by allowing negative timestamps, -and can therefore represent timestamps that predate the -introduction of UTC and are some other flavor of Universal Time (UT). -Some implementations support leap seconds, in contradiction to POSIX. -.PP -The -.B ctime -function is deprecated starting in C23. -Callers can use -.B localtime_r -and -.B strftime -instead. -.PP -The .B localtime and .B gmtime functions +convert an integer, pointed to by +.IR clock , +and return pointers to .q "tm" structures, described below. +If the integer is out of range for conversion, +these functions return a null pointer. The .B localtime function corrects for the time zone and any time zone adjustments (such as Daylight Saving Time in the United States). -.PP The .B gmtime -function -converts to Coordinated Universal Time. +function converts to Coordinated Universal Time. .PP The -.B asctime -function -converts a time value contained in a -.q "tm" -structure to a string, -as shown in the above example, -and returns a pointer to the string. -This function is deprecated starting in C23. -Callers can use -.B strftime -instead. +.BI * clock +timestamp represents the time in seconds since 1970-01-01 00:00:00 +Coordinated Universal Time (UTC). +The POSIX standard says that timestamps must be nonnegative +and must ignore leap seconds. +Many implementations extend POSIX by allowing negative timestamps, +and can therefore represent timestamps that predate the +introduction of UTC and are some other flavor of Universal Time (UT). +Some implementations support leap seconds, in contradiction to POSIX. .PP The .B mktime @@ -202,6 +150,52 @@ returns the difference between two calendar times, expressed in seconds. .PP The +.B asctime +function +converts a time value contained in a +.q "tm" +structure to a pointer to a +string of the form +.br +.ce +.eo +Thu Nov 24 18:22:48 1986\n\0 +.br +.ec +Years requiring fewer than four characters are padded with leading zeroes. +For years longer than four characters, the string is of the form +.br +.ce +.eo +Thu Nov 24 18:22:48 81986\n\0 +.ec +.br +with five spaces before the year. +This unusual format is designed to make it less likely that older +software that expects exactly 26 bytes of output will mistakenly output +misleading values for out-of-range years. +This function is deprecated starting in C23. +Callers can use +.B strftime +instead. +.PP +The +.B ctime +function is equivalent to calliing +.B localtime +and then calling +.B asctime +on the result. +Like +.BR asctime , +this function is deprecated starting in C23. +Callers can use +.B localtime +and +.B strftime +instead. +.PP +The .BR ctime_r , .BR localtime_r , .BR gmtime_r , -- 2.47.1

* private.h (STD_INSPIRED): Default to 1 on NetBSD, since NetBSD has these functions. --- private.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/private.h b/private.h index de816077..0a546e02 100644 --- a/private.h +++ b/private.h @@ -810,7 +810,11 @@ extern long altzone; */ #ifndef STD_INSPIRED -# define STD_INSPIRED 0 +# ifdef __NetBSD__ +# define STD_INSPIRED 1 +# else +# define STD_INSPIRED 0 +# endif #endif #if STD_INSPIRED # if TZ_TIME_T || !defined offtime -- 2.47.1

* Makefile (zdump.o): Depend on private.h. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e00b0f32..f1ce7abb 100644 --- a/Makefile +++ b/Makefile @@ -1360,8 +1360,8 @@ date.o: private.h difftime.o: private.h localtime.o: private.h tzdir.h tzfile.h strftime.o: localtime.c private.h tzdir.h tzfile.h -zdump.o: version.h -zic.o: private.h tzfile.h tzdir.h version.h +zdump.o: private.h version.h +zic.o: private.h tzdir.h tzfile.h version.h .PHONY: ALL INSTALL all .PHONY: check check_mild check_time_t_alternatives -- 2.47.1

* asctime.c (ctime): Call localtime and asctime, not localtime_r and ctime_r. --- asctime.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/asctime.c b/asctime.c index 3817182e..1bfcafe9 100644 --- a/asctime.c +++ b/asctime.c @@ -162,5 +162,8 @@ ctime_r(const time_t *timep, char *buf) char * ctime(const time_t *timep) { - return ctime_r(timep, buf_ctime); + /* Do not call localtime_r, as C23 requires ctime to initialize the + static storage that localtime updates. */ + struct tm *tmp = localtime(timep); + return tmp ? asctime(tmp) : NULL; } -- 2.47.1
participants (1)
-
Paul Eggert