tzdata: update to 2018g
[unleashed.git] / contrib / tzdata / ziguard.awk
blobe3c729832dd37059d74ddcfd48244898a5aee934
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
8 # values.
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
13 # rearguard format.
15 BEGIN {
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"
25 /^Zone/ { zone = $2 }
27 DATAFORM != "main" {
28 in_comment = /^#/
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
36 } else {
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) {
48 if ((Rule_Eire \
49 || (Zone_Dublin_post_1968 && $(in_comment + 3) == "IST/GMT")) \
50 == vanguard) {
51 uncomment = in_comment
52 } else {
53 comment_out = !in_comment
57 # If this line should differ due to Namibia using Rule SAVE suffixes,
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) {
66 if ((Rule_Namibia \
67 ? ($(in_comment + 9) ~ /^-/ \
68 || ($(in_comment + 9) == 0 && $(in_comment + 10) == "CAT")) \
69 : $(in_comment + 1) == "2:00" && $(in_comment + 2) == "Namibia") \
70 == vanguard) {
71 uncomment = in_comment
72 } else {
73 comment_out = !in_comment
77 if (uncomment) {
78 sub(/^#/, "")
80 if (comment_out) {
81 sub(/^/, "#")
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")
88 sub(/25:00/, " 1:00")
92 # If a Link line is followed by a Zone line for the same data, comment
93 # out the Link line. This can happen if backzone overrides a Link
94 # with a Zone.
95 /^Link/ {
96 linkline[$3] = NR
98 /^Zone/ {
99 sub(/^Link/, "#Link", line[linkline[$2]])
102 { line[NR] = $0 }
104 END {
105 for (i = 1; i <= NR; i++)
106 print line[i]