From cec7d9e2e83f8a3faa2367e0d45383a1557889ed Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 10 Jan 2022 11:31:54 -0800
Subject: [PROPOSED] Improve rearguard port of post-2087 Morocco
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* ziguard.awk: In rearguard format predict perpetual standard time
instead of perpetual DST after May 2087 in Morocco.  This is a
better match for old non-POSIX clients that don’t grok negative DST.
Problem reported by Almaz Mingaleev.
---
 ziguard.awk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ziguard.awk b/ziguard.awk
index 6888c27..2be6d52 100644
--- a/ziguard.awk
+++ b/ziguard.awk
@@ -104,13 +104,19 @@ DATAFORM != "main" {
   }
   if (!vanguard && $1 == "Rule" && $2 == "Morocco" && 2019 <= $3) {
     if ($9 == "0") {
+      last_std_date = $3 " " $6 " " $7 "  " $8
       sub(/\t0\t/, "\t1:00\t")
     } else {
       sub(/\t-1:00\t/, "\t0\t")
     }
   }
   if (!vanguard && $1 == "1:00" && $2 == "Morocco" && $3 == "+01/+00") {
-    sub(/1:00\tMorocco\t\+01\/\+00$/, "0:00\tMorocco\t+00/+01")
+    # This introduces a transition from 01:59:59 +00 to 03:00:00 +01
+    # with both times being standard (i.e., a change to standard UT offset).
+    # This is rearguard's way to approximate the actual prediction,
+    # which is that of an ordinary transition from DST to standard time.
+    sub(/1:00\tMorocco\t\+01\/\+00$/,
+	"0:00\tMorocco\t+00/+01\t" last_std_date "\n\t\t\t 1:00\t-\t+01")
   }
 }
 
-- 
2.32.0

