From 6b32cae2605bdd091b49b7b69321ee024814ff4d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 30 Jul 2022 08:55:51 -0700 Subject: [PATCH 1/3] Simplify subsecond precision handling * ziguard.awk (get_rounding_subst): Remove support for two-operand #STDOFF, as one-operand suffices if the transition times are in UT. All uses changed. --- asia | 4 ++-- northamerica | 4 ++-- ziguard.awk | 28 +++++++--------------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/asia b/asia index a35d46dd..f481f399 100644 --- a/asia +++ b/asia @@ -857,8 +857,8 @@ Rule HK 1973 only - Dec 30 3:30 1:00 S Rule HK 1979 only - May 13 3:30 1:00 S Rule HK 1979 only - Oct 21 3:30 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] - #STDOFF 7:36:41.7 0:36:41.7 -Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 0:36:42 + #STDOFF 7:36:41.7 +Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 29 17:00u 8:00 - HKT 1941 Jun 15 3:00 8:00 1:00 HKST 1941 Oct 1 4:00 8:00 0:30 HKWT 1941 Dec 25 diff --git a/northamerica b/northamerica index a8858698..94f6ea38 100644 --- a/northamerica +++ b/northamerica @@ -353,8 +353,8 @@ Rule NYC 1921 1966 - Apr lastSun 2:00 1:00 D Rule NYC 1921 1954 - Sep lastSun 2:00 0 S Rule NYC 1955 1966 - Oct lastSun 2:00 0 S # Zone NAME STDOFF RULES FORMAT [UNTIL] - #STDOFF -4:56:01.6 12:03:58.4 -Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58 + #STDOFF -4:56:01.6 +Zone America/New_York -4:56:02 - LMT 1883 Nov 18 17:00u -5:00 US E%sT 1920 -5:00 NYC E%sT 1942 -5:00 US E%sT 1946 diff --git a/ziguard.awk b/ziguard.awk index c39e0d65..2f11f827 100644 --- a/ziguard.awk +++ b/ziguard.awk @@ -68,17 +68,6 @@ function round_to_second(timestamp, \ seconds / 3600, seconds / 60 % 60, seconds % 60) } -function get_rounding_subst(time, subst) -{ - if (DATAFORM == "vanguard") { - subst[0] = round_to_second(time) - subst[1] = time - } else { - subst[0] = time - subst[1] = round_to_second(time) - } -} - BEGIN { dataform_type["vanguard"] = 1 dataform_type["main"] = 1 @@ -86,9 +75,6 @@ BEGIN { # The command line should set DATAFORM. if (!dataform_type[DATAFORM]) exit 1 - - stdoff_subst[0] = 0 - until_subst[0] = 0 } /^Zone/ { zone = $2 } @@ -208,20 +194,20 @@ DATAFORM != "main" { # Prefer subseconds in vanguard form, whole seconds otherwise. if ($1 == "#STDOFF") { - get_rounding_subst($2, stdoff_subst) - if ($3) { - get_rounding_subst($3, until_subst) + stdoff = $2 + rounded_stdoff = round_to_second(stdoff) + if (DATAFORM == "vanguard") { + stdoff_subst[0] = rounded_stdoff + stdoff_subst[1] = stdoff } else { - until_subst[0] = 0 + stdoff_subst[0] = stdoff + stdoff_subst[1] = rounded_stdoff } } else if (stdoff_subst[0]) { stdoff_column = 2 * /^Zone/ + 1 stdoff_column_val = $stdoff_column if (stdoff_column_val == stdoff_subst[0]) { sub(stdoff_subst[0], stdoff_subst[1]) - if (until_subst[0] && $NF == until_subst[0]) { - sub(until_subst[0], until_subst[1]) - } } else if (stdoff_column_val != stdoff_subst[1]) { stdoff_subst[0] = 0 } -- 2.34.1