xref: /netbsd-src/lib/libc/time/zdump.8 (revision 18b32cd19a7876a54ee1a4164d407422179e38ed)
1.\" $NetBSD: zdump.8,v 1.26 2025/01/23 22:44:22 christos Exp $
2.\" @(#)zdump.8	8.2
3.\" This file is in the public domain, so clarified as of
4.\" 2009-05-17 by Arthur David Olson.
5.\" .TH zdump 8
6.Dd January 23, 2025
7.Dt ZDUMP 8
8.Os
9.Sh NAME
10.Nm zdump
11.Nd timezone dumper
12.Sh SYNOPSIS
13.Nm zdump
14.Op Fl \-version
15.Op Fl v
16.Op Fl V
17.Op Fl c Ar [loyear,]highyear
18.Op Ar timezone ...
19.Nm zdump
20.Fl t
21.Ar [lotime,]hightime
22.Op Ar zonename ...
23.Sh DESCRIPTION
24The
25.Nm
26program prints the current time in each
27.Ar timezone
28named on the command line.
29A
30.Dv timezone
31of
32.Dq \&-
33is treated as if it were
34.Pa /dev/stdin ;
35this can be used to pipe TZif data into
36.Nm zdump .
37.Sh OPTIONS
38.Bl -tag -width XXXXXXXXX -compact
39.It Fl \-version
40Output version information and exit.
41.It Fl \-help
42Output short usage message and exit.
43.It Fl i
44Output a description of time intervals.
45For each
46.Ar timezone
47on the command line, output an interval-format description of the
48timezone.
49See
50.Sx "INTERVAL FORMAT"
51below.
52.It Fl v
53Output a verbose description of time intervals.
54For each
55.Ar timezon
56on the command line,
57print the times at the two extreme time values,
58the times (if present) at and just beyond the boundaries of years that
59.Xr localtime 3
60and
61.Xr gmtime 3
62can represent, and
63the times both one second before and exactly at
64each detected time discontinuity.
65Each line is followed by
66.Em isdst=D
67where
68.Em D
69is positive, zero, or negative depending on whether
70the given time is daylight saving time, standard time,
71or an unknown time type, respectively.
72Each line is also followed by
73.Em gmtoff=N
74if the given local time is known to be
75.Em N
76seconds east of Greenwich.
77.It Fl c Ar [loyear,]highyear
78Cut off interval output at the given year(s).
79Cutoff times are computed using the proleptic Gregorian calendar with year 0
80and with Universal Time (UT) ignoring leap seconds.
81Cutoffs are at the start of each year, where the lower-bound
82timestamp is inclusive and the upper is exclusive; for example,
83.Em "\&-c 1970,2070"
84selects transitions on or after 1970-01-01 00:00:00 UTC
85and before 2070-01-01 00:00:00 UTC.
86The default cutoff is
87.Em \&-500,2500 .
88.It Fl t Ar [lotime,]hightime
89Cut off interval output at the given time(s),
90given in decimal seconds since 1970-01-01 00:00:00
91Coordinated Universal Time (UTC).
92The
93.Ar timezone
94determines whether the count includes leap seconds.
95As with
96.Fl c ,
97the cutoff's lower bound is inclusive and its upper bound is exclusive.
98.It Fl V
99Like
100.Fl v ,
101except omit output concerning extreme time and year values.
102This generates output that is easier to compare to that of
103implementations with different time representations.
104.El
105.Sh "INTERVAL FORMAT"
106.Pp
107The interval format is a compact text representation that is intended
108to be both human- and machine-readable.
109It consists of an empty line, then a line
110.Dq TZ=string
111where
112.Dv string
113is a double-quoted string giving the timezone, a second line
114.Dq \&- \&- interval
115describing the time interval before the first transition if any, and
116zero or more following lines
117.Dq date time interval
118one line for each transition time and following interval.
119Fields are separated by single tabs.
120.Pp
121Dates are in
122.Dv yyyy-mm-dd
123format and times are in 24-hour
124.Dv hhmmss
125format where
126.Dv hh < 24 .
127Times are in local time immediately after the transition.
128A time interval description consists of a UT offset in signed
129.Dv \&+- hh : mm : ss
130format, a time zone abbreviation, and an isdst flag.
131An abbreviation that equals the UT offset is omitted; other abbreviations are
132double-quoted strings unless they consist of one or more alphabetic
133characters.
134An isdst flag is omitted for standard time, and otherwise
135is a decimal integer that is unsigned and positive (typically 1) for
136daylight saving time and negative for unknown.
137.Pp
138In times and in UT offsets with absolute value less than 100 hours,
139the seconds are omitted if they are zero, and
140the minutes are also omitted if they are also zero.
141Positive UT offsets are east of Greenwich.  The UT offset \&-00 denotes a UT
142placeholder in areas where the actual offset is unspecified; by
143convention, this occurs when the UT offset is zero and the time zone
144abbreviation begins with
145.Dq \&-
146or is
147.Dq zzz .
148.Pp
149In double-quoted strings, escape sequences represent unusual
150characters.  The escape sequences are \es for space, and \e", \e\e,
151\ef, \en, \er, \et, and \ev with their usual meaning in the C
152programming language.
153E.g., the double-quoted string
154.Sq "CET\es\e"\e\e"
155represents the character sequence
156.Sq CET
157.Pp
158Here is an example of the output, with the leading empty line omitted.
159(This example is shown with tab stops set far enough apart so that the
160tabbed columns line up.)
161.Bd -literal
162TZ="Pacific/Honolulu"
163.Ed
164.Bl -column "XXXX-XX-XX" "HH:MM:SS" "-HHMMSS" "TZT" "X" -compact
165.It - Ta - Ta -103126 Ta LMT Ta
166.It 1896-01-13 Ta 12:01:26 Ta -1030 Ta HST Ta
167.It 1933-04-30 Ta 03 Ta -0930 Ta HDT Ta 1
168.It 1933-05-21 Ta 11 Ta -1030 Ta HST Ta
169.It 1942-02-09 Ta 03 Ta -0930 Ta HDT Ta 1
170.It 1945-08-14 Ta 13:30 Ta -0930 Ta HPT Ta 1
171.It 1945-09-30 Ta 01 Ta -1030 Ta HST Ta
172.It 1947-06-08 Ta 02:30 Ta -10 Ta HST Ta
173.El
174.Pp
175Here, local time begins 10 hours, 31 minutes and 26 seconds west of
176UT, and is a standard time abbreviated LMT.  Immediately after the
177first transition, the date is 1896-01-13 and the time is 12:01:26, and
178the following time interval is 10.5 hours west of UT, a standard time
179abbreviated HST.
180Immediately after the second transition, the date is
1811933-04-30 and the time is 03:00:00 and the following time interval is
1829.5 hours west of UT, is abbreviated HDT, and is daylight saving time.
183Immediately after the last transition the date is 1947-06-08 and the
184time is 02:30:00, and the following time interval is 10 hours west of
185UT, a standard time abbreviated HST.
186.Pp
187Here are excerpts from another example:
188.Bd -literal
189TZ="Europe/Astrakhan"
190.Ed
191.Bl -column "XXXX-XX-XX" "HH:MM:SS" "-HH:MM:SS" "TZT" "X" -compact
192.It - Ta - Ta +031212 Ta LMT Ta
193.It 1924-04-30 Ta 23:47:48 Ta +03 Ta Ta
194.It 1930-06-21 Ta 01 Ta +04 Ta Ta
195.It 1981-04-01 Ta 01 Ta +05 Ta Ta 1
196.It 1981-09-30 Ta 23 Ta +04 Ta Ta
197.It \&... Ta Ta Ta Ta
198.It 2014-10-26 Ta 01 Ta +03 Ta Ta
199.It 2016-03-27 Ta 03 Ta +04 Ta Ta
200.El
201.Pp
202This time zone is east of UT, so its UT offsets are positive.  Also,
203many of its time zone abbreviations are omitted since they duplicate
204the text of the UT offset.
205.Sh LIMITATIONS
206Time discontinuities are found by sampling the results returned by
207.Xr localtime 3
208at twelve-hour intervals.
209This works in all real-world cases;
210one can construct artificial time zones for which this fails.
211.Pp
212In the
213.Fl v
214and
215.Fl V
216output,
217.Dq UT
218denotes the value returned by
219.Xr gmtime 3 ,
220which uses UTC for modern timestamps and some other UT flavor for
221timestamps that predate the introduction of UTC.
222No attempt is currently made to have the output use
223.Dq UTC
224for newer and
225.Dq UT
226for older timestamps, partly because the exact date of the
227introduction of UTC is problematic.
228.Sh SEE ALSO
229.Xr localtime 3 ,
230.Xr tzfile 5 ,
231.Xr zic 8
232