1.\" $OpenBSD: zic.8,v 1.6 2024/09/18 17:05:50 millert Exp $ 2.Dd $Mdocdate: September 18 2024 $ 3.Dt ZIC 8 4.Os 5.Sh NAME 6.Nm zic 7.Nd time zone compiler 8.Sh SYNOPSIS 9.Nm zic 10.Bk -words 11.Op Fl v 12.Op Fl d Ar directory 13.Op Fl L Ar leapsecondfilename 14.Op Fl l Ar timezone 15.Op Fl p Ar timezone 16.Op Ar filename ... 17.Ek 18.Sh DESCRIPTION 19.Nm 20reads text from the file(s) named on the command line 21and creates the time conversion information files specified in this input. 22If a 23.Ar filename 24is 25.Dq Fl , 26the standard input is read. 27.Pp 28These options are available: 29.Bl -tag -width "-d directory" 30.It Fl d Ar directory 31Create time conversion information files in the named directory rather than 32in the standard directory named below. 33.It Fl L Ar leapsecondfilename 34Read leap second information from the file with the given name. 35If this option is not used, 36no leap second information appears in output files. 37.It Fl l Ar timezone 38Use the given time zone as local time. 39.Nm 40will act as if the input contained a link line of the form 41.Pp 42.Dl Link timezone localtime 43.It Fl p Ar timezone 44Use the given time zone's rules when handling POSIX-format 45time zone environment variables. 46.Nm 47will act as if the input contained a link line of the form 48.Pp 49.Dl Link timezone posixrules 50.It Fl v 51Complain if a year that appears in a data file is outside the range 52of years representable by 53.Xr time 3 54values. 55Also complain if a time of 24:00 56(which cannot be handled by pre-1998 versions of 57.Nm zic ) 58appears in the input. 59.El 60.Pp 61Input lines are made up of fields. 62Fields are separated from one another by any number of whitespace characters. 63Leading and trailing whitespace on input lines is ignored. 64An unquoted sharp character (#) in the input introduces a comment which extends 65to the end of the line the sharp character appears on. 66White space characters and sharp characters may be enclosed in double quotes 67(") if they're to be used as part of a field. 68Any line that is blank (after comment stripping) is ignored. 69Non-blank lines are expected to be of one of three types: 70rule lines, zone lines, and link lines. 71.Pp 72Names (such as month names) must be in English and are case insensitive. 73Abbreviations, if used, must be unambiguous in context. 74.Pp 75A rule line has the form: 76.Bd -literal -offset indent 77Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S 78.Ed 79.Pp 80For example: 81.Bd -literal -offset indent 82Rule US 1967 1973 - Apr lastSun 2:00 1:00 D 83.Ed 84.Pp 85The fields that make up a rule line are: 86.Bl -tag -width "LETTER/S" 87.It Cm NAME 88Gives the (arbitrary) name of the set of rules this rule is part of. 89.It Cm FROM 90Gives the first year in which the rule applies. 91Any integer year can be supplied; the Gregorian calendar is assumed. 92The word 93.Em minimum 94(or an abbreviation) means the minimum year representable as an integer. 95The word 96.Em maximum 97(or an abbreviation) means the maximum year representable as an integer. 98Rules can describe times that are not representable as time values, 99with the unrepresentable times ignored; this allows rules to be portable 100among hosts with differing time value types. 101.It Cm TO 102Gives the final year in which the rule applies. 103In addition to 104.Em minimum 105and 106.Em maximum 107(as above), 108the word 109.Em only 110(or an abbreviation) 111may be used to repeat the value of the 112.Em FROM 113field. 114.It Cm TYPE 115Gives the type of year in which the rule applies. 116This field is obsolete and should always be 117.Dq Fl . 118.It Cm IN 119Names the month in which the rule takes effect. 120Month names may be abbreviated. 121.It Cm ON 122Gives the day on which the rule takes effect. 123Recognized forms include: 124.Pp 125.Bl -tag -width "SunXX25" -compact -offset indent 126.It 5 127the fifth of the month 128.It lastSun 129the last Sunday in the month 130.It lastMon 131the last Monday in the month 132.It Sun>=8 133first Sunday on or after the eighth 134.It Sun<=25 135last Sunday on or before the 25th 136.El 137.Pp 138Names of days of the week may be abbreviated or spelled out in full. 139Note that there must be no spaces within the 140.Em ON 141field. 142.It Cm AT 143Gives the time of day at which the rule takes effect. 144Recognized forms include: 145.Pp 146.Bl -tag -width "1:28:14" -compact -offset indent 147.It 2 148time in hours 149.It 2:00 150time in hours and minutes 151.It 15:00 15224-hour format time (for times after noon) 153.It 1:28:14 154time in hours, minutes, and seconds 155.It \&- 156equivalent to 0 157.El 158.Pp 159where hour 0 is midnight at the start of the day, 160and hour 24 is midnight at the end of the day. 161Any of these forms may be followed by the letter 162.Em w 163if the given time is local 164.Dq wall clock 165time, 166.Em s 167if the given time is local 168.Dq standard 169time, or 170.Em u 171(or 172.Em g 173or 174.Em z ) 175if the given time is universal time; 176in the absence of an indicator, 177wall clock time is assumed. 178.It Cm SAVE 179Gives the amount of time to be added to local standard time when the rule is in 180effect. 181This field has the same format as the 182.Em AT 183field 184(although, of course, the 185.Em w 186and 187.Em s 188suffixes are not used). 189.It Cm LETTER/S 190Gives the 191.Dq variable part 192(for example, the 193.Dq S 194or 195.Dq D 196in 197.Dq EST 198or 199.Dq EDT ) 200of time zone abbreviations to be used when this rule is in effect. 201If this field is 202.Dq \- , 203the variable part is null. 204.El 205.Pp 206A zone line has the form: 207.Bd -literal -offset 3n 208Zone NAME GMTOFF RULES/SAVE FORMAT [UNTILYEAR [MONTH [DAY [TIME]]]] 209.Ed 210.Pp 211For example: 212.Bd -literal -offset 3n 213Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00 214.Ed 215.Pp 216The fields that make up a zone line are: 217.Bl -tag -width GMTOFF 218.It Cm NAME 219The name of the time zone. 220This is the name used in creating the time conversion information file for the 221zone. 222.It Cm GMTOFF 223The amount of time to add to UTC to get standard time in this zone. 224This field has the same format as the 225.Em AT 226and 227.Em SAVE 228fields of rule lines; 229begin the field with a minus sign if time must be subtracted from UTC. 230.It Cm RULES/SAVE 231The name of the rule(s) that apply in the time zone or, 232alternately, an amount of time to add to local standard time. 233If this field is 234.Dq \- 235then standard time always applies in the time zone. 236.It Cm FORMAT 237The format for time zone abbreviations in this time zone. 238The pair of characters 239.Em %s 240is used to show where the 241.Dq variable part 242of the time zone abbreviation goes. 243Alternately, a format can use the pair of characters 244.Em %z 245to stand for the UTC offset in the form 246.No \(+- Ns Em hh , 247.No \(+- Ns Em hhmm , 248or 249.No \(+- Ns Em hhmmss , 250using the shortest form that does not lose information, where 251.Em hh , 252.Em mm , 253and 254.Em ss 255are the hours, minutes, and seconds east (+) or west (\(mi) of UTC. 256Alternately, 257a slash 258.Pq \&/ 259separates standard and daylight abbreviations. 260.It Cm UNTILYEAR [MONTH [DAY [TIME]]] 261The time at which the UTC offset or the rule(s) change for a location. 262It is specified as a year, a month, a day, and a time of day. 263If this is specified, 264the time zone information is generated from the given UTC offset 265and rule change until the time specified. 266The month, day, and time of day have the same format as the IN, ON, and AT 267fields of a rule; trailing fields can be omitted, and default to the 268earliest possible value for the missing fields. 269.Pp 270The next line must be a 271.Dq continuation 272line; this has the same form as a zone line except that the 273string 274.Dq Zone 275and the name are omitted, as the continuation line will 276place information starting at the time specified as the 277.Dq until 278information in the previous line in the file used by the previous line. 279Continuation lines may contain 280.Dq until 281information, just as zone lines do, indicating that the next line is a further 282continuation. 283.El 284.Pp 285A link line has the form: 286.Bd -literal -offset indent 287Link LINK-FROM LINK-TO 288.Ed 289.Pp 290For example: 291.Bd -literal -offset indent 292Link Europe/Istanbul Asia/Istanbul 293.Ed 294.Pp 295The 296.Em LINK-FROM 297field should appear as the 298.Em NAME 299field in some zone line; 300the 301.Em LINK-TO 302field is used as an alternate name for that zone. 303.Pp 304Except for continuation lines, 305lines may appear in any order in the input. 306.Pp 307Lines in the file that describes leap seconds have the following form: 308.Bd -literal -offset indent 309Leap YEAR MONTH DAY HH:MM:SS CORR R/S 310.Ed 311.Pp 312For example: 313.Bd -literal -offset indent 314Leap 1974 Dec 31 23:59:60 + S 315.Ed 316.Pp 317The 318.Em YEAR , 319.Em MONTH , 320.Em DAY , 321and 322.Em HH:MM:SS 323fields tell when the leap second happened. 324The 325.Em CORR 326field 327should be 328.Dq + 329if a second was added 330or 331.Dq - 332if a second was skipped. 333.\" There's no need to document the following, since it's impossible for more 334.\" than one leap second to be inserted or deleted at a time. 335.\" The C Standard is in error in suggesting the possibility. 336.\" See Terry J Quinn, The BIPM and the accurate measure of time, 337.\" Proc IEEE 79, 7 (July 1991), 894-905. 338.\" or 339.\" .q ++ 340.\" if two seconds were added 341.\" or 342.\" .q -- 343.\" if two seconds were skipped. 344The 345.Em R/S 346field should be (an abbreviation of) 347.Dq Stationary 348if the leap second time given by the other fields should be interpreted as UTC 349or (an abbreviation of) 350.Dq Rolling 351if the leap second time given by the other fields should be interpreted as 352local wall clock time. 353.Sh EXTENDED EXAMPLE 354Here is an extended example of 355.Nm 356input, intended to illustrate many of its features. 357.Bd -literal 358# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S 359Rule Swiss 1940 only - Nov 2 0:00 1:00 S 360Rule Swiss 1940 only - Dec 31 0:00 0 - 361Rule Swiss 1941 1942 - May Sun>=1 2:00 1:00 S 362Rule Swiss 1941 1942 - Oct Sun>=1 0:00 0 363 364Rule EU 1977 1980 - Apr Sun>=1 1:00u 1:00 S 365Rule EU 1977 only - Sep lastSun 1:00u 0 - 366Rule EU 1978 only - Oct 1 1:00u 0 - 367Rule EU 1979 1995 - Sep lastSun 1:00u 0 - 368Rule EU 1981 max - Mar lastSun 1:00u 1:00 S 369Rule EU 1996 max - Oct lastSun 1:00u 0 - 370 371# Zone NAME GMTOFF RULES FORMAT UNTIL 372Zone Europe/Zurich 0:34:08 - LMT 1848 Sep 12 373 0:29:44 - BMT 1894 Jun 374 1:00 Swiss CE%sT 1981 375 1:00 EU CE%sT 376 377Link Europe/Zurich Switzerland 378.Ed 379.Pp 380In this example, the zone is named Europe/Zurich 381but it has an alias as Switzerland. 382Zurich was 34 minutes and 8 seconds west of GMT until 1848-09-12 at 00:00, 383when the offset changed to 29 minutes and 44 seconds. 384After 1894-06-01 at 00:00 Swiss daylight saving rules 385(defined with lines beginning with "Rule Swiss") apply, 386and the GMT offset became one hour. 387From 1981 to the present, 388EU daylight saving rules have applied, 389and the UTC offset has remained at one hour. 390.Pp 391In 1940, daylight saving time applied from 392November 2 at 00:00 to December 31 at 00:00. 393In 1941 and 1942, daylight saving time applied 394from the first Sunday in May at 02:00 395to the first Sunday in October at 00:00. 396The pre-1981 EU daylight-saving rules have no effect here, 397but are included for completeness. 398Since 1981, 399daylight saving has begun on the last Sunday in March at 01:00 UTC. 400Until 1995 it ended the last Sunday in September at 01:00 UTC, 401but this changed to the last Sunday in October starting in 1996. 402.Pp 403For purposes of display, 404"LMT" and "BMT" were initially used, respectively. 405Since Swiss rules and later EU rules were applied, 406the display name for the timezone has been CET for standard time 407and CEST for daylight saving time. 408.Sh FILES 409.Bl -tag -width "/usr/share/zoneinfo" -compact 410.It Pa /etc/localtime 411link to local time zone 412.It Pa /usr/share/zoneinfo 413standard directory used for created files 414.El 415.Sh SEE ALSO 416.Xr ctime 3 , 417.Xr tzfile 5 , 418.Xr zdump 8 419.Sh CAVEATS 420For areas with more than two types of local time, 421you may need to use local standard time in the 422.Em AT 423field of the earliest transition time's rule to ensure that 424the earliest transition time recorded in the compiled file is correct. 425.Pp 426If, 427for a particular zone, 428a clock advance caused by the start of daylight saving 429coincides with and is equal to 430a clock retreat caused by a change in UTC offset, 431.Nm 432produces a single transition to daylight saving at the new UTC offset 433(without any change in wall clock time). 434To get separate transitions 435use multiple zone continuation lines 436specifying transition instants using universal time. 437.\" This file is in the public domain, so clarified as of 438.\" 2009-05-17 by Arthur David Olson. 439