xref: /netbsd-src/lib/libc/time/zic.8 (revision 796c32c94f6e154afc9de0f63da35c91bb739b45)
1.\"	$NetBSD: zic.8,v 1.27 2017/10/24 17:38:17 christos Exp $
2.Dd October 24, 2017
3.Dt ZIC 8
4.Os
5.Sh NAME
6.Nm zic
7.Nd time zone compiler
8.Sh SYNOPSIS
9.Nm
10.Op Fl \-version
11.Op Fl d Ar directory
12.Op Fl L Ar leapsecondfilename
13.Op Fl l Ar localtime
14.Op Fl p Ar posixrules
15.Op Fl s
16.Op Fl v
17.Op Fl y Ar command
18.Op Ar Filename ...
19.Sh DESCRIPTION
20.Nm
21reads text from the file(s) named on the command line
22and creates the time conversion information files specified in this input.
23If a
24.Ar filename
25is
26.Ar \&- ,
27the standard input is read.
28.Pp
29These options are available:
30.Bl -tag -width XXXXXXXXXX -compact
31.It Fl \-version
32Output version information and exit.
33.It Fl d Ar directory
34Create time conversion information files in the named directory rather than
35in the standard directory named below.
36.It Fl L Ar leapsecondfilename
37Read leap second information from the file with the given name.
38If this option is not used,
39no leap second information appears in output files.
40.It Fl l Ar timezone
41Use the given time zone as local time.
42.Nm
43will act as if the input contained a link line of the form
44.Dl Link	timezone	localtime
45.It Fl p Ar timezone
46Use the given time zone's rules when handling POSIX-format
47time zone environment variables.
48.Nm
49will act as if the input contained a link line of the form
50.Dl Link	timezone	posixrules
51.It Fl s
52Limit time values stored in output files to values that are the same
53whether they're taken to be signed or unsigned.
54You can use this option to generate SVVS-compatible files.
55.It Fl v
56Be more verbose, and complain about the following situations:
57.Bl -dash
58.It The input specifies a link to a link.
59.It A year that appears in a data file is outside the range
60.It A time of 24:00 or more appears in the input.
61Pre-1998 versions of
62.Xr zic 8
63prohibit 24:00, and pre-2007 versions prohibit times greater than 24:00.
64.It A rule goes past the start or end of the month.
65Pre-2004 versions of
66.Xr zic 8
67prohibit this.
68.It The output file does not contain all the information about the
69long-term future of a zone, because the future cannot be summarized as
70an extended POSIX TZ string.
71For example, as of 2013 this problem
72occurs for Iran's daylight-saving rules for the predicted future, as
73these rules are based on the Iranian calendar, which cannot be
74represented.
75.It The output contains data that may not be handled properly by client
76code designed for older
77.Xr zic 8
78output formats.
79These compatibility issues affect only time stamps
80before 1970 or after the start of 2038.
81.It A time zone abbreviation has fewer than 3 characters.
82POSIX requires at least 3.
83.It An output file name contains a byte that is not an ASCII letter,
84.Dq - ,
85.Dq / ,
86or
87.Dq _ ;
88or it
89or it contains a file name component that contains more than 14 bytes
90or that starts with
91.Dq - .
92.El
93.Pp
94Input files should be text files, that is, they should be a series of
95zero or more lines, each ending in a newline byte and containing at
96most 511 bytes, and without any
97.Dv NUL
98bytes.
99The input text's encoding
100is typically UTF-8 or ASCII; it should have a unibyte representation
101for the POSIX Portable Character Set (PPCS)
102.%U http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html
103and the encoding's non-unibyte characters should consist entirely of
104non-PPCS bytes.
105Non-PPCS characters typically occur only in comments:
106although output file names and time zone abbreviations can contain
107nearly any character, other software will work better if these are
108limited to the restricted syntax described under the
109.Op v
110option.
111.Pp
112Input lines are made up of fields.
113Fields are separated from one another by one or more white space characters.
114The white space characters are space, form feed, carriage return, newline,
115tab, and vertical tab.
116Leading and trailing white space on input lines is ignored.
117An unquoted sharp character (#) in the input introduces a comment which extends
118to the end of the line the sharp character appears on.
119White space characters and sharp characters may be enclosed in double
120quotes
121.Pq \&"
122.\" XXX "
123if they're to be used as part of a field.
124Any line that is blank (after comment stripping) is ignored.
125Non-blank lines are expected to be of one of three types:
126rule lines, zone lines, and link lines.
127.Pp
128Names must be in English and are case insensitive.
129They appear in several contexts, and include month and weekday names
130and keywords such as
131.Dq maximum ,
132.Dq only ,
133.Dq Rolling ,
134and
135.Dq Zone .
136A name can be abbreviated by omitting all but an initial prefix; any
137abbreviation must be unambiguous in context.
138.Pp
139A rule line has the form
140.Dl Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
141For example:
142.Dl Rule	US	1967	1973	\-	Apr	lastSun	2:00	1:00	D
143The fields that make up a rule line are:
144.Bl -tag -width "LETTER/S" -compact
145.It NAME
146Gives the (arbitrary) name of the set of rules this rule is part of.
147.It FROM
148Gives the first year in which the rule applies.
149Any integer year can be supplied; the proleptic Gregorian calendar is assumed.
150The word
151.Em minimum
152(or an abbreviation) means the minimum year representable as an integer.
153The word
154.Em maximum
155(or an abbreviation) means the maximum year representable as an integer.
156Rules can describe times that are not representable as time values,
157with the unrepresentable times ignored; this allows rules to be portable
158among hosts with differing time value types.
159.It TO
160Gives the final year in which the rule applies.
161In addition to
162.Em minimum
163and
164.Em maximum
165(as above),
166the word
167.Em only
168(or an abbreviation)
169may be used to repeat the value of the
170.Em FROM
171field.
172.It TYPE
173should be
174.Dq -
175and is present for compatibility with older versions of
176.Nm
177in which it could contain year types.
178.It IN
179Names the month in which the rule takes effect.
180Month names may be abbreviated.
181.It ON
182Gives the day on which the rule takes effect.
183Recognized forms include:
184.Bl -tag -width lastSun -compact -offset indent
185.It 5
186the fifth of the month
187.It lastSun
188the last Sunday in the month
189.It lastMon
190the last Monday in the month
191.It Sun\*[Ge]8
192first Sunday on or after the eighth
193.It Sun\*[Le]25
194last Sunday on or before the 25th
195.El
196Names of days of the week may be abbreviated or spelled out in full.
197A weekday name (e.g.,
198.Dq Sunday )
199or a weekday name preceded by
200.Dq last
201(e.g.,
202.Dq lastSunday )
203may be abbreviated or spelled out in full.
204Note that there must be no spaces within the
205.Em ON
206field.
207.It AT
208Gives the time of day at which the rule takes effect.
209Recognized forms include:
210.Bl -tag -width "1X28X14" -compact -offset indent
211.It 2
212time in hours
213.It 2:00
214time in hours and minutes
215.It 15:00
21624-hour format time (for times after noon)
217.It 1:28:14
218time in hours, minutes, and seconds
219.It \-
220equivalent to 0
221.El
222where hour 0 is midnight at the start of the day,
223and hour 24 is midnight at the end of the day.
224Any of these forms may be followed by the letter
225.Em w
226if the given time is local
227.Dq wall clock
228time,
229.Em s
230if the given time is local
231.Dq standard
232time, or
233.Em u
234(or
235.Em g
236or
237.Em z )
238if the given time is universal time;
239in the absence of an indicator,
240wall clock time is assumed.
241The intent is that a rule line describes the instants when a
242clock/calendar set to the type of time specified in the
243.Em AT
244field would show the specified date and time of day.
245.It SAVE
246Gives the amount of time to be added to local standard time when the rule is in
247effect.
248This field has the same format as the
249.Em AT
250field
251(although, of course, the
252.Em w
253and
254.Em s
255suffixes are not used).
256Only the sum of standard time and this amount matters; for example,
257.Nm
258does not distinguish a 10:30 standard time plus an 0:30
259.Em SAVE
260from a 10:00 standard time plus a 1:00
261.Em SAVE .
262.It LETTER/S
263Gives the
264.Dq variable part
265(for example, the
266.Dq S
267or
268.Dq D
269in
270.Dq EST
271or
272.Dq EDT )
273of time zone abbreviations to be used when this rule is in effect.
274If this field is
275.Em \&- ,
276the variable part is null.
277.El
278.Pp
279A zone line has the form
280.sp
281.Dl Zone	NAME			GMTOFF	RULES/SAVE	FORMAT	[UNTILYEAR [MONTH [DAY [TIME]]]]
282For example:
283.Dl Zone	Australia/Adelaide	9:30	Aus	AC%sT	1971 Oct 31 2:00
284The fields that make up a zone line are:
285.Bl -tag -width "RULES/SAVE" -compact
286.It NAME
287The name of the time zone.
288This is the name used in creating the time conversion information file for the
289zone.
290It should not contain a file name component
291.Dq .
292or
293.Dq .. ;
294a file name component is a maximal substring that does not contain
295.Dq / .
296.It GMTOFF
297The amount of time to add to UT to get standard time in this zone.
298This field has the same format as the
299.Em AT
300and
301.Em SAVE
302fields of rule lines;
303begin the field with a minus sign if time must be subtracted from UT.
304.It RULES/SAVE
305The name of the rule(s) that apply in the time zone or,
306alternatively, an amount of time to add to local standard time.
307If this field is
308.Em \&-
309then standard time always applies in the time zone.
310When an amount of time is given, only the sum of standard time and
311this amount matters.
312.It FORMAT
313The format for time zone abbreviations in this time zone.
314The pair of characters
315.Em %s
316is used to show where the
317.Dq variable part
318of the time zone abbreviation goes.
319Alternately, a format can use the pair of characters
320.Em %z
321+to stand for the UTC offset in the form
322.Em \(+- hh ,
323.Em \(+- hhmm ,
324or
325.Em \(+- hhmmss ,
326using the shortest form that does not lose information, where
327.Em hh ,
328.Em mm ,
329and
330.Em ss
331are the hours, minutes, and seconds east (+) or west (\(mi) of UTC.
332Alternatively,
333a slash
334.Pq \&/
335separates standard and daylight abbreviations.
336To conform to POSIX, a time zone abbreviation should contain only
337alphanumeric ASCII characters, "+" and "\*-".
338.It UNTILYEAR [MONTH [DAY [TIME]]]
339The time at which the UT offset or the rule(s) change for a location.
340It is specified as a year, a month, a day, and a time of day.
341If this is specified,
342the time zone information is generated from the given UT offset
343and rule change until the time specified, which is interpreted using
344the rules in effect just before the transition.
345The month, day, and time of day have the same format as the IN, ON, and AT
346fields of a rule; trailing fields can be omitted, and default to the
347earliest possible value for the missing fields.
348.El
349The next line must be a
350.Dq continuation
351line; this has the same form as a zone line except that the
352string
353.Dq Zone
354and the name are omitted, as the continuation line will
355place information starting at the time specified as the
356.Em until
357information in the previous line in the file used by the previous line.
358Continuation lines may contain
359.Em until
360information, just as zone lines do, indicating that the next line is a further
361continuation.
362.Pp
363If a zone changes at the same instant that a rule would otherwise take
364effect in the earlier zone or continuation line, the rule is ignored.
365In a single zone it is an error if two rules take effect at the same
366instant, or if two zone changes take effect at the same instant.
367.Pp
368A link line has the form
369.Dl Link	TARGET	LINK-NAME
370For example:
371.Dl Link	Europe/Istanbul	Asia/Istanbul
372The
373.Em TARGET
374field should appear as the
375.Em NAME
376field in some zone line.
377The
378.Em LINK-NAME
379field is used as an alternative name for that zone;
380it has the same syntax as a zone line's
381.Em NAME
382field.
383.Pp
384Except for continuation lines,
385lines may appear in any order in the input.
386However, the behavior is unspecified if multiple zone or link lines
387define the same name, or if the source of one link line is the target
388of another.
389.Pp
390Lines in the file that describes leap seconds have the following form:
391.Dl Leap	YEAR	MONTH	DAY	HH:MM:SS	CORR	R/S
392For example:
393.Dl Leap	1974	Dec	31	23:59:60	+	S
394The
395.Em YEAR ,
396.Em MONTH ,
397.Em DAY ,
398and
399.Em HH:MM:SS
400fields tell when the leap second happened.
401The
402.Em CORR
403field
404should be
405.Dq \&+
406if a second was added
407or
408.Dq \&-
409if a second was skipped.
410The
411.Em R/S
412field
413should be (an abbreviation of)
414.Dq Stationary
415if the leap second time given by the other fields should be interpreted as UTC
416or
417(an abbreviation of)
418.Dq Rolling
419if the leap second time given by the other fields should be interpreted as
420local wall clock time.
421.El
422.Sh EXTENDED EXAMPLE
423Here is an extended example of
424.Ic zic
425input, intended to illustrate many of its features.
426.Bl -column -compact "# Rule" "Swiss" "FROM" "1995" "TYPE" "Oct" "lastSun" "1:00u" "SAVE" "LETTER/S"
427.It # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
428.It Rule	Swiss	1941	1942	-	May	Mon>=1	1:00	1:00	S
429.It Rule	Swiss	1941	1942	-	Oct	Mon>=1	2:00	0	-
430.Pp
431.It Rule	EU	1977	1980	-	Apr	Sun>=1	1:00u	1:00	S
432.It Rule	EU	1977	only	-	Sep	lastSun	1:00u	0	-
433.It Rule	EU	1978	only	-	Oct	 1	1:00u	0	-
434.It Rule	EU	1979	1995	-	Sep	lastSun	1:00u	0	-
435.It Rule	EU	1981	max	-	Mar	lastSun	1:00u	1:00	S
436.It Rule	EU	1996	max	-	Oct	lastSun	1:00u	0	-
437.El
438.Pp
439.Bl -column -compact "# Zone" "Europe/Zurich" "0:34:08" "RULES/SAVE" "FORMAT" "UNTIL"
440.It # Zone	NAME	GMTOFF	RULES/SAVE	FORMAT	UNTIL
441.It Zone	Europe/Zurich	0:34:08	-	LMT	1853 Jul 16
442.It 		0:29:44	-	BMT	1894 Jun
443.It 		1:00	Swiss	CE%sT	1981
444.It 		1:00	EU	CE%sT
445.It Link	Europe/Zurich	Switzerland
446.El
447.Pp
448In this example, the zone is named Europe/Zurich but it has an alias
449as Switzerland.
450This example says that Zurich was 34 minutes and 8
451seconds west of UT until 1853-07-16 at 00:00, when the legal offset
452was changed to 7\(de\|26\(fm\|22.50\(sd; although this works out to
4530:29:45.50, the input format cannot represent fractional seconds so it
454is rounded here.
455After 1894-06-01 at 00:00 Swiss daylight saving rules
456(defined with lines beginning with "Rule Swiss") apply, and the UT offset
457became one hour.
458From 1981 to the present, EU daylight saving rules have
459applied, and the UTC offset has remained at one hour.
460.Pp
461In 1941 and 1942, daylight saving time applied from the first Monday
462in May at 01:00 to the first Monday in October at 02:00.
463The pre-1981 EU daylight-saving rules have no effect
464here, but are included for completeness.
465Since 1981, daylight
466saving has begun on the last Sunday in March at 01:00 UTC.
467Until 1995 it ended the last Sunday in September at 01:00 UTC,
468but this changed to the last Sunday in October starting in 1996.
469.Pp
470For purposes of
471display, "LMT" and "BMT" were initially used, respectively.
472Since
473Swiss rules and later EU rules were applied, the display name for the
474time zone has been CET for standard time and CEST for daylight saving
475time.
476.Sh NOTES
477For areas with more than two types of local time,
478you may need to use local standard time in the
479.Em AT
480field of the earliest transition time's rule to ensure that
481the earliest transition time recorded in the compiled file is correct.
482.Pp
483If,
484for a particular zone,
485a clock advance caused by the start of daylight saving
486coincides with and is equal to
487a clock retreat caused by a change in UT offset,
488.Ic zic
489produces a single transition to daylight saving at the new UT offset
490(without any change in wall clock time).
491To get separate transitions
492use multiple zone continuation lines
493specifying transition instants using universal time.
494.Pp
495Time stamps well before the Big Bang are silently omitted from the output.
496This works around bugs in software that mishandles large negative time stamps.
497Call it sour grapes, but pre-Big-Bang time stamps are physically suspect anyway.
498The pre-Big-Bang cutoff time is approximate and may change in future versions.
499.Sh FILES
500.Pa /usr/share/zoneinfo
501- standard directory used for created files
502.Sh SEE ALSO
503.Xr ctime 3 ,
504.Xr tzfile 5 ,
505.Xr zdump 8
506.\" @(#)zic.8	8.6
507.\" This file is in the public domain, so clarified as of
508.\" 2009-05-17 by Arthur David Olson.
509