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