1.\" $NetBSD: zic.8,v 1.33 2019/07/03 15:50:16 christos Exp $ 2.Dd July 2, 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 \-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 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 590Lines in the file that describes leap seconds have the following form: 591.Pp 592.Dl Leap YEAR MONTH DAY HH:MM:SS CORR R/S 593.Pp 594For example: 595.Pp 596.Dl Leap 2016 Dec 31 23:59:60 + S 597.Pp 598The 599.Em YEAR , 600.Em MONTH , 601.Em DAY , 602and 603.Em HH:MM:SS 604fields tell when the leap second happened. 605The 606.Em CORR 607field 608should be 609.Qq \&+ 610if a second was added 611or 612.Qq \&- 613if a second was skipped. 614The 615.Em R/S 616field 617should be (an abbreviation of) 618.Qq Stationary 619if the leap second time given by the other fields should be interpreted as UTC 620or 621(an abbreviation of) 622.Qq Rolling 623if the leap second time given by the other fields should be interpreted as 624local (wall clock) time. 625.Sh EXTENDED EXAMPLE 626Here is an extended example of 627.Ic zic 628input, intended to illustrate many of its features. 629In this example, the EU rules are for the European Union 630and for its predecessor organization, the European Communities. 631.Pp 632.Bl -column -compact -offset indent "# Rule" "Swiss" "FROM" "1995" "TYPE" "Oct" "lastSun" "1:00u" "SAVE" "LETTER/S" 633.It # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S 634.It Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S 635.It Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - 636.Pp 637.It Rule EU 1977 1980 - Apr Sun>=1 1:00u 1:00 S 638.It Rule EU 1977 only - Sep lastSun 1:00u 0 - 639.It Rule EU 1978 only - Oct 1 1:00u 0 - 640.It Rule EU 1979 1995 - Sep lastSun 1:00u 0 - 641.It Rule EU 1981 max - Mar lastSun 1:00u 1:00 S 642.It Rule EU 1996 max - Oct lastSun 1:00u 0 - 643.El 644.Pp 645.Bl -column -compact -offset indent "# Zone" "Europe/Zurich" "0:29:45.50" "RULES/SAVE" "FORMAT" "UNTIL" 646.It # Zone NAME STDOFF RULES/SAVE FORMAT [UNTIL] 647.It Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 648.It 0:29:45.50 - BMT 1894 Jun 649.It 1:00 Swiss CE%sT 1981 650.It 1:00 EU CE%sT 651.Pp 652.El 653.Bl -column -compact -offset indent "# Zone" "Europe/Zurich" "0:34:08" "RULES/SAVE" "FORMAT" "UNTIL" 654.It Link Europe/Zurich Europe/Vaduz 655.El 656.Pp 657In this example, the timezone is named Europe/Zurich but it has an alias 658as Europe/Vaduz. 659This example says that Zurich was 34 minutes and 8 660seconds east of UT until 1853-07-16 at 00:00, when the legal offset 661was changed to 7\(de\|26\(fm\|22.50\(sd; which this works out to 6620:29:45.50; 663.Nm 664treats this by rounding it to 0:29:46. 665After 1894-06-01 at 00:00 the UT offset became one hour 666and Swiss daylight saving rules (defined with lines beginning with 667.Qq "Rule Swiss" 668apply. 669From 1981 to the present, EU daylight saving rules have 670From 1981 to the present, EU daylight saving rules have 671.Pp 672In 1941 and 1942, daylight saving time applied from the first Monday 673in May at 01:00 to the first Monday in October at 02:00. 674The pre-1981 EU daylight-saving rules have no effect 675here, but are included for completeness. 676Since 1981, daylight 677saving has begun on the last Sunday in March at 01:00 UTC. 678Until 1995 it ended the last Sunday in September at 01:00 UTC, 679but this changed to the last Sunday in October starting in 1996. 680.Pp 681For purposes of display, 682.Qq LMT 683and 684.Qq BMT 685were initially used, respectively. 686Since 687Swiss rules and later EU rules were applied, the time zone abbreviation 688has been CET for standard time and CEST for daylight saving 689time. 690.Sh FILES 691Input files use the format described in this section; output files use 692.Xr tzfile 5 693format. 694.Bl -tag -width /usr/share/zoneinfo -compact 695.It Pa /etc/localtime 696Default local timezone file 697.It Pa /usr/share/zoneinfo 698Default timezone information directory 699.El 700.Sh NOTES 701For areas with more than two types of local time, 702you may need to use local standard time in the 703.Em AT 704field of the earliest transition time's rule to ensure that 705the earliest transition time recorded in the compiled file is correct. 706.Pp 707If, 708for a particular timezone, 709a clock advance caused by the start of daylight saving 710coincides with and is equal to 711a clock retreat caused by a change in UT offset, 712.Ic zic 713produces a single transition to daylight saving at the new UT offset 714without any change in local (wall clock) time. 715To get separate transitions 716use multiple zone continuation lines 717specifying transition instants using universal time. 718.Sh SEE ALSO 719.Xr tzfile 5 , 720.Xr zdump 8 721.\" @(#)zic.8 8.6 722.\" This file is in the public domain, so clarified as of 723.\" 2009-05-17 by Arthur David Olson. 724