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.
7 # When converting to vanguard form, the output can use negative SAVE
10 # When converting to rearguard form, the output uses only nonnegative
11 # SAVE values. The idea is for the output data to simulate the behavior
12 # of the input data as best it can within the constraints of the
16 dataform_type["vanguard"] = 1
17 dataform_type["main"] = 1
18 dataform_type["rearguard"] = 1
20 # The command line should set DATAFORM.
21 if (!dataform_type[DATAFORM]) exit 1
22 vanguard = DATAFORM == "vanguard"
29 uncomment = comment_out = 0
31 # If the line should differ due to Czechoslovakia using negative SAVE values,
32 # uncomment the desired version and comment out the undesired one.
33 if (zone == "Europe/Prague" && /1947 Feb 23/) {
34 if (($(in_comment + 2) != "-") == vanguard) {
35 uncomment = in_comment
37 comment_out = !in_comment
41 # If this line should differ due to Ireland using negative SAVE values,
42 # uncomment the desired version and comment out the undesired one.
43 Rule_Eire = /^#?Rule[\t ]+Eire[\t ]/
44 Zone_Dublin_post_1968 \
45 = (zone == "Europe/Dublin" && /^#?[\t ]+[01]:00[\t ]/ \
46 && (!$(in_comment + 4) || 1968 < $(in_comment + 4)))
47 if (Rule_Eire || Zone_Dublin_post_1968) {
49 || (Zone_Dublin_post_1968 && $(in_comment + 3) == "IST/GMT")) \
51 uncomment = in_comment
53 comment_out = !in_comment
57 # If this line should differ due to Namibia using negative SAVE values,
58 # uncomment the desired version and comment out the undesired one.
59 Rule_Namibia = /^#?Rule[\t ]+Namibia[\t ]/
60 Zone_using_Namibia_rule \
61 = (zone == "Africa/Windhoek" \
62 && ($(in_comment + 2) == "Namibia" \
63 || (1994 <= $(in_comment + 4) && $(in_comment + 4) <= 2017) \
64 || in_comment + 3 == NF))
65 if (Rule_Namibia || Zone_using_Namibia_rule) {
67 ? ($(in_comment + 9) ~ /^-/ \
68 || ($(in_comment + 9) == 0 && $(in_comment + 10) == "CAT")) \
69 : $(in_comment + 1) == "2:00" && $(in_comment + 2) == "Namibia") \
71 uncomment = in_comment
73 comment_out = !in_comment
84 # In rearguard format, change the Japan rule line with "Sat>=8 25:00"
85 # to "Sun>=9 1:00", to cater to zic before 2007 and to older Java.
86 if (!vanguard && $1 == "Rule" && $7 == "Sat>=8" && $8 == "25:00") {
87 sub(/Sat>=8/, "Sun>=9")
91 # In rearguard format, change the Morocco lines with negative SAVE values
92 # to use positive SAVE values.
93 if (!vanguard && $1 == "Rule" && $2 == "Morocco" && $4 == 2018 \
95 sub(/\t2018\t/, "\t2017\t")
97 if (!vanguard && $1 == "Rule" && $2 == "Morocco" && 2019 <= $3) {
99 sub(/\t0\t/, "\t1:00\t")
101 sub(/\t-1:00\t/, "\t0\t")
104 if (!vanguard && $1 == "1:00" && $2 == "Morocco" && $3 == "+01/+00") {
105 sub(/1:00\tMorocco\t\+01\/\+00$/, "0:00\tMorocco\t+00/+01")
109 # If a Link line is followed by a Zone line for the same data, comment
110 # out the Link line. This can happen if backzone overrides a Link
116 sub(/^Link/, "#Link", line[linkline[$2]])
122 for (i = 1; i <= NR; i++)