>From 8539a448ebc8897e40d62f16dc4d0ada3f07b3ca Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 1 Nov 2018 10:47:57 -0700
Subject: [PROPOSED 2/2] Bring back 2019-2037 Morocco Ramadan predictions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It appears that last week���s guess that Morocco would abolish DST
transitions during Ramadan was probably wrong.  (Thanks to Maamar
Abdelkader.)  Resurrect these transitions.  They now use negative
DST due to the time zone change, so convert them to positive DST
in rearguard format.
* NEWS: Mention this.
* africa (Morocco, Africa/Casablanca, Africa/El_Aaiun):
Predict Ramadan transitions for 2019 through 2037.
* ziguard.awk: Convert Moroccan negative DST to positive DST.
---
 NEWS        | 13 +++++++++
 africa      | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 ziguard.awk | 19 ++++++++++++-
 3 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index f9bbc0c..5a2e86e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,19 @@ News for the tz database
 
 Unreleased, experimental changes
 
+  Changes to future timestamps
+
+    Guess that Morocco will continue to fall back just before and
+    spring forward just after Ramadan, the practice since 2012.
+    (Thanks to Maamar Abdelkader.)  This means Morocco will observe
+    negative DST during Ramadan in main and vanguard formats, and in
+    rearguard format it stays in the +00 timezone and observes
+    ordinary DST in all months other than Ramadan.  As before, extend
+    this guesswork to the year 2037.  As a consequence, Morocco is
+    scheduled to observe three DST transitions in some Gregorian years
+    (e.g., 2033) due to the mismatch between the Gregorian and Islamic
+    calendars.
+
   Changes to past tm_isdst flags
 
     For the recent Morocco change, the tm_isdst flag should be 1 from
diff --git a/africa b/africa
index 2a15e1e..a83c387 100644
--- a/africa
+++ b/africa
@@ -849,6 +849,39 @@ Zone Indian/Mauritius	3:50:00 -	LMT	1907 # Port Louis
 # of 60 minutes to the regular Moroccan timezone.
 # From Matt Johnson (2018-10-28):
 # http://www.sgg.gov.ma/Portals/1/BO/2018/BO_6720-bis_Ar.pdf
+#
+# From Maamar Abdelkader (2018-11-01):
+# We usually move clocks back the previous week end and come back to the +1
+# the week end after....  The government does not announce yet the decision
+# about this temporary change.  But it s 99% sure that it will be the case,
+# as in previous years.  An unofficial survey was done these days, showing
+# that 64% of asked peopke are ok for moving from +1 to +0 during Ramadan.
+# https://leconomiste.com/article/1035870-enquete-l-economiste-sunergia-64-des-marocains-plebiscitent-le-gmt-pendant-ramadan
+#
+# From Paul Eggert (2018-11-01):
+# For now, guess that Morocco will fall back at 03:00 the last Sunday
+# before Ramadan, and spring forward at 02:00 the first Sunday after
+# Ramadan, as this has been the practice since 2012.  To implement this,
+# transition dates for 2019 through 2037 were determined by running the
+# following program under GNU Emacs 26.1.
+# (let ((islamic-year 1440))
+#   (require 'cal-islam)
+#   (while (< islamic-year 1460)
+#     (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
+#           (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
+#           (sunday 0))
+#       (while (/= sunday (mod (setq a (1- a)) 7)))
+#       (while (/= sunday (mod b 7))
+#         (setq b (1+ b)))
+#       (setq a (calendar-gregorian-from-absolute a))
+#       (setq b (calendar-gregorian-from-absolute b))
+#       (insert
+#        (format
+#         (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 3:00\t-1:00\t-\n"
+#                 "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 2:00\t0\t-\n")
+#         (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
+#         (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
+#     (setq islamic-year (+ 1 islamic-year))))
 
 # RULE	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Morocco	1939	only	-	Sep	12	 0:00	1:00	-
@@ -892,13 +925,53 @@ Rule	Morocco	2017	only	-	May	21	 3:00	0	-
 Rule	Morocco	2017	only	-	Jul	 2	 2:00	1:00	-
 Rule	Morocco	2018	only	-	May	13	 3:00	0	-
 Rule	Morocco	2018	only	-	Jun	17	 2:00	1:00	-
+Rule	Morocco	2019	only	-	May	 5	 3:00	-1:00	-
+Rule	Morocco	2019	only	-	Jun	 9	 2:00	0	-
+Rule	Morocco	2020	only	-	Apr	19	 3:00	-1:00	-
+Rule	Morocco	2020	only	-	May	24	 2:00	0	-
+Rule	Morocco	2021	only	-	Apr	11	 3:00	-1:00	-
+Rule	Morocco	2021	only	-	May	16	 2:00	0	-
+Rule	Morocco	2022	only	-	Mar	27	 3:00	-1:00	-
+Rule	Morocco	2022	only	-	May	 8	 2:00	0	-
+Rule	Morocco	2023	only	-	Mar	19	 3:00	-1:00	-
+Rule	Morocco	2023	only	-	Apr	23	 2:00	0	-
+Rule	Morocco	2024	only	-	Mar	10	 3:00	-1:00	-
+Rule	Morocco	2024	only	-	Apr	14	 2:00	0	-
+Rule	Morocco	2025	only	-	Feb	23	 3:00	-1:00	-
+Rule	Morocco	2025	only	-	Apr	 6	 2:00	0	-
+Rule	Morocco	2026	only	-	Feb	15	 3:00	-1:00	-
+Rule	Morocco	2026	only	-	Mar	22	 2:00	0	-
+Rule	Morocco	2027	only	-	Feb	 7	 3:00	-1:00	-
+Rule	Morocco	2027	only	-	Mar	14	 2:00	0	-
+Rule	Morocco	2028	only	-	Jan	23	 3:00	-1:00	-
+Rule	Morocco	2028	only	-	Feb	27	 2:00	0	-
+Rule	Morocco	2029	only	-	Jan	14	 3:00	-1:00	-
+Rule	Morocco	2029	only	-	Feb	18	 2:00	0	-
+Rule	Morocco	2029	only	-	Dec	30	 3:00	-1:00	-
+Rule	Morocco	2030	only	-	Feb	10	 2:00	0	-
+Rule	Morocco	2030	only	-	Dec	22	 3:00	-1:00	-
+Rule	Morocco	2031	only	-	Jan	26	 2:00	0	-
+Rule	Morocco	2031	only	-	Dec	14	 3:00	-1:00	-
+Rule	Morocco	2032	only	-	Jan	18	 2:00	0	-
+Rule	Morocco	2032	only	-	Nov	28	 3:00	-1:00	-
+Rule	Morocco	2033	only	-	Jan	 9	 2:00	0	-
+Rule	Morocco	2033	only	-	Nov	20	 3:00	-1:00	-
+Rule	Morocco	2033	only	-	Dec	25	 2:00	0	-
+Rule	Morocco	2034	only	-	Nov	 5	 3:00	-1:00	-
+Rule	Morocco	2034	only	-	Dec	17	 2:00	0	-
+Rule	Morocco	2035	only	-	Oct	28	 3:00	-1:00	-
+Rule	Morocco	2035	only	-	Dec	 2	 2:00	0	-
+Rule	Morocco	2036	only	-	Oct	19	 3:00	-1:00	-
+Rule	Morocco	2036	only	-	Nov	23	 2:00	0	-
+Rule	Morocco	2037	only	-	Oct	 4	 3:00	-1:00	-
+Rule	Morocco	2037	only	-	Nov	15	 2:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Africa/Casablanca	-0:30:20 -	LMT	1913 Oct 26
 			 0:00	Morocco	+00/+01	1984 Mar 16
 			 1:00	-	+01	1986
 			 0:00	Morocco	+00/+01	2018 Oct 28  3:00
-			 1:00	-	+01
+			 1:00	Morocco	+01/+00
 
 # Western Sahara
 #
@@ -914,7 +987,7 @@ Zone Africa/Casablanca	-0:30:20 -	LMT	1913 Oct 26
 Zone Africa/El_Aaiun	-0:52:48 -	LMT	1934 Jan # El Aai��n
 			-1:00	-	-01	1976 Apr 14
 			 0:00	Morocco	+00/+01	2018 Oct 28  3:00
-			 1:00	-	+01
+			 1:00	Morocco	+01/+00
 
 # Mozambique
 #
diff --git a/ziguard.awk b/ziguard.awk
index e3c7298..e8ef49e 100644
--- a/ziguard.awk
+++ b/ziguard.awk
@@ -54,7 +54,7 @@ DATAFORM != "main" {
     }
   }
 
-  # If this line should differ due to Namibia using Rule SAVE suffixes,
+  # If this line should differ due to Namibia using negative SAVE values,
   # uncomment the desired version and comment out the undesired one.
   Rule_Namibia = /^#?Rule[\t ]+Namibia[\t ]/
   Zone_using_Namibia_rule \
@@ -87,6 +87,23 @@ DATAFORM != "main" {
     sub(/Sat>=8/, "Sun>=9")
     sub(/25:00/, " 1:00")
   }
+
+  # In rearguard format, change the Morocco lines with negative SAVE values
+  # to use positive SAVE values.
+  if (!vanguard && $1 == "Rule" && $2 == "Morocco" && $4 == 2018 \
+      && $6 == "Oct") {
+    sub(/\t2018\t/, "\t2017\t")
+  }
+  if (!vanguard && $1 == "Rule" && $2 == "Morocco" && 2019 <= $3) {
+    if ($9 == "0") {
+      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")
+  }
 }
 
 # If a Link line is followed by a Zone line for the same data, comment
-- 
2.19.1

