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