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