1 # Convert tzdata source into vanguard or rearguard form.
3 # Contributed by Paul Eggert. This file is in the public domain.
5 # This is not a general-purpose converter; it is designed for current tzdata.
6 # It just converts from current source to main, vanguard, and rearguard forms.
7 # Although it might be nice for it to be idempotent, or to be useful
8 # for converting back and forth between vanguard and rearguard formats,
9 # it does not do these nonessential tasks now.
11 # Although main and vanguard forms are currently equivalent,
12 # this need not always be the case.
14 # When converting to vanguard form, the output can use negative SAVE
17 # When converting to rearguard form, the output uses only nonnegative
18 # SAVE values. The idea is for the output data to simulate the behavior
19 # of the input data as best it can within the constraints of the
23 dataform_type["vanguard"] = 1
24 dataform_type["main"] = 1
25 dataform_type["rearguard"] = 1
27 # The command line should set DATAFORM.
28 if (!dataform_type[DATAFORM]) exit 1
29 vanguard = DATAFORM == "vanguard"
36 uncomment = comment_out = 0
38 # If this line should differ due to Czechoslovakia using negative SAVE values,
39 # uncomment the desired version and comment out the undesired one.
40 if (zone == "Europe/Prague" && /1947 Feb 23/) {
41 if (($(in_comment + 2) != "-") == vanguard) {
42 uncomment = in_comment
44 comment_out = !in_comment
48 # If this line should differ due to Ireland using negative SAVE values,
49 # uncomment the desired version and comment out the undesired one.
50 Rule_Eire = /^#?Rule[\t ]+Eire[\t ]/
51 Zone_Dublin_post_1968 \
52 = (zone == "Europe/Dublin" && /^#?[\t ]+[01]:00[\t ]/ \
53 && (!$(in_comment + 4) || 1968 < $(in_comment + 4)))
54 if (Rule_Eire || Zone_Dublin_post_1968) {
56 || (Zone_Dublin_post_1968 && $(in_comment + 3) == "IST/GMT")) \
58 uncomment = in_comment
60 comment_out = !in_comment
64 # If this line should differ due to Namibia using negative SAVE values,
65 # uncomment the desired version and comment out the undesired one.
66 Rule_Namibia = /^#?Rule[\t ]+Namibia[\t ]/
67 Zone_using_Namibia_rule \
68 = (zone == "Africa/Windhoek" \
69 && ($(in_comment + 2) == "Namibia" \
70 || (1994 <= $(in_comment + 4) && $(in_comment + 4) <= 2017) \
71 || in_comment + 3 == NF))
72 if (Rule_Namibia || Zone_using_Namibia_rule) {
74 ? ($(in_comment + 9) ~ /^-/ \
75 || ($(in_comment + 9) == 0 && $(in_comment + 10) == "CAT")) \
76 : $(in_comment + 1) == "2:00" && $(in_comment + 2) == "Namibia") \
78 uncomment = in_comment
80 comment_out = !in_comment
91 # In rearguard format, change the Japan rule line with "Sat>=8 25:00"
92 # to "Sun>=9 1:00", to cater to zic before 2007 and to older Java.
93 if (!vanguard && $1 == "Rule" && $7 == "Sat>=8" && $8 == "25:00") {
94 sub(/Sat>=8/, "Sun>=9")
98 # In rearguard format, change the Morocco lines with negative SAVE values
99 # to use positive SAVE values.
100 if (!vanguard && $1 == "Rule" && $2 == "Morocco" && $4 == 2018 \
102 sub(/\t2018\t/, "\t2017\t")
104 if (!vanguard && $1 == "Rule" && $2 == "Morocco" && 2019 <= $3) {
106 sub(/\t0\t/, "\t1:00\t")
108 sub(/\t-1:00\t/, "\t0\t")
111 if (!vanguard && $1 == "1:00" && $2 == "Morocco" && $3 == "+01/+00") {
112 sub(/1:00\tMorocco\t\+01\/\+00$/, "0:00\tMorocco\t+00/+01")
116 # If a Link line is followed by a Zone line for the same data, comment
117 # out the Link line. This can happen if backzone overrides a Link
123 sub(/^Link/, "#Link", line[linkline[$2]])
129 for (i = 1; i <= NR; i++)