[tz] posix for asia/tehran is wrong

Paul Eggert eggert at cs.ucla.edu
Fri Nov 30 08:41:48 UTC 2018


Mark wrote:
> 
>     The Iranian DST starts on March 22 and ends on September 22 each
>     year with the exception of leapyears in which the DST starts and
>     ends one day prior.

No, Iranian DST starts at 24:00 on Farvardin 1 and ends at 24:00 on Shahrivar 30 
in the Persian calendar, and this disagrees with the Gregorian approximation you 
mentioned (assuming you meant 00:00 on the stated days). For example, in 2029 
DST is scheduled to start March 21 and end September 21 even though 2029 is not 
a leap year. This is documented in the 'asia' file.

There is no simple Gregorian equivalent to the Iranian rules' use of the Persian 
calendar, so we might as well stick with the current Gregorian approximation for 
far-future years. That being said, this is a good time as any to extend the 
table of exact transitions past its current cutoff year 2037, as the 2037 cutoff 
dates back to when zic couldn't reliably handle dates past 2038. A reasonable 
cutoff for Iranian DST prediction is to stop just before the year 2091, as there 
is some controversy over how to interpret current Iranian law for that year. (Of 
course the DST rules will probably change before then....)

Proposed patch attached.
-------------- next part --------------
From 81d167e8896c4da92305d14fd081bd2c0e88ddb6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Fri, 30 Nov 2018 00:35:26 -0800
Subject: [PROPOSED] Extend Iranian exact dates to 2090
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* NEWS: Mention this.
* asia (Iran): Extend table to 2090 for exact rules, with the
same approximation after that.  Give source code for the
table’s future.  Switch transitions from 00:00 to 24:00 the previous
day, since that seems to be how it’s specified in the law.
---
 NEWS |   7 ++
 asia | 211 +++++++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 160 insertions(+), 58 deletions(-)

diff --git a/NEWS b/NEWS
index 18f4850..9df130f 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,13 @@ Unreleased, experimental changes
     (e.g., 2033) due to the mismatch between the Gregorian and Islamic
     calendars.
 
+    The table of exact transitions for Iranian DST has been extended.
+    It formerly stopped at the year 2037 in a nod to 32-bit time_t.
+    It now stops at 2090, as there is doubt about how the Persian
+    calendar will treat 2091.  This change predicts DST transitions in
+    2038-9, 2042-3, and 2046-7 to occur one day later than previously
+    predicted.  As before, post-cutoff transitions are approximated.
+
   Changes to past and future timestamps
 
     Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
diff --git a/asia b/asia
index 72faab4..38ba69c 100644
--- a/asia
+++ b/asia
@@ -1309,12 +1309,55 @@ Zone Asia/Jayapura	9:22:48 -	LMT	1932 Nov
 # leap year calculation involved.  There has never been any serious
 # plan to change that law....
 #
-# From Paul Eggert (2006-03-22):
+# From Paul Eggert (2018-11-30):
 # Go with Shanks & Pottenger before Sept. 1991, and with Pournader thereafter.
-# I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates,
-# stopping after 2037 when 32-bit time_t's overflow.
-# That cal-persia used Birashk's approximation, which disagrees with the solar
-# calendar predictions for the year 2025, so I corrected those dates by hand.
+# I used the following code in GNU Emacs 25.2 to generate the "Rule Iran"
+# lines from 2008 through 2087.  This code uses Ed Reingold's cal-persia
+# which uses Birashk's approximation, and this disagrees with the solar
+# calendar predictions for the Persian years 1404 (Gregorian 2025)
+# and 1437 (Gregorian 2058), so this code fixes those two years by hand.
+# My source for this disagreement is Table 15.1, page 264, of:
+# Edward M. Reingold and Nachum Dershowitz, Calendrical Calculations:
+# The Ultimate Edition, Cambridge University Press (2018).
+# https://www.cambridge.org/fr/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition
+# Page 258, footnote 2, of this book says there is some dispute over what will
+# happen in 2091 (and some other years after that), so this code
+# stops in 2087, as 2088 and 2089 agree with the "max" rule below.
+# (let* ((persian-year 1387)
+#	 (persian-lastyear 1466)
+#	 (exceptional-persian-years '(1404 1437)) ; from Table 15.1, page 264
+#	 prevyear
+#	 (persian-beginrange persian-year))
+#   (require 'cal-persia)
+#   (while (<= persian-year persian-lastyear)
+#     (let*
+#	  ((incr (if (member persian-year exceptional-persian-years) 1 0))
+#	   (pa (+ incr (calendar-persian-to-absolute (list 1 1 persian-year))))
+#	   (pa1 (+ (if (member (1+ persian-year) exceptional-persian-years) 1 0)
+#		   (calendar-persian-to-absolute (list 1 1 (1+ persian-year)))))
+#	   (pb (+ incr (calendar-persian-to-absolute (list 6 30 persian-year))))
+#	   (ga (calendar-gregorian-from-absolute pa))
+#	   (ga1 (calendar-gregorian-from-absolute pa1))
+#	   (gb (calendar-gregorian-from-absolute pb))
+#	   (gayear (calendar-extract-year ga)))
+#	(when (not prevyear)
+#	  (setq prevyear gayear))
+#	(when (or (= persian-year persian-lastyear)
+#		  (/= (calendar-extract-day ga) (calendar-extract-day ga1)))
+#	  (insert
+#	   (format
+#	    (concat "Rule\tIran\t%d\t%s\t-\t%s\t%2d\t24:00\t1:00\t-\n"
+#		    "Rule\tIran\t%d\t%s\t-\t%s\t%2d\t24:00\t0\t-\n")
+#	    prevyear
+#	    (if (= prevyear gayear) "only" gayear)
+#	    (calendar-month-name (calendar-extract-month ga) t)
+#	    (calendar-extract-day ga)
+#	    prevyear
+#	    (if (= prevyear gayear) "only" gayear)
+#	    (calendar-month-name (calendar-extract-month gb) t)
+#	    (calendar-extract-day gb)))
+#	  (setq prevyear nil)))
+#     (setq persian-year (+ 1 persian-year))))
 #
 # From Oscar van Vlijmen (2005-03-30), writing about future
 # discrepancies between cal-persia and the Iranian calendar:
@@ -1349,61 +1392,113 @@ Zone Asia/Jayapura	9:22:48 -	LMT	1932 Nov
 # thirtieth day of Shahrivar.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Iran	1978	1980	-	Mar	21	0:00	1:00	-
-Rule	Iran	1978	only	-	Oct	21	0:00	0	-
-Rule	Iran	1979	only	-	Sep	19	0:00	0	-
-Rule	Iran	1980	only	-	Sep	23	0:00	0	-
-Rule	Iran	1991	only	-	May	 3	0:00	1:00	-
-Rule	Iran	1992	1995	-	Mar	22	0:00	1:00	-
-Rule	Iran	1991	1995	-	Sep	22	0:00	0	-
-Rule	Iran	1996	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	1996	only	-	Sep	21	0:00	0	-
-Rule	Iran	1997	1999	-	Mar	22	0:00	1:00	-
-Rule	Iran	1997	1999	-	Sep	22	0:00	0	-
-Rule	Iran	2000	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2000	only	-	Sep	21	0:00	0	-
-Rule	Iran	2001	2003	-	Mar	22	0:00	1:00	-
-Rule	Iran	2001	2003	-	Sep	22	0:00	0	-
-Rule	Iran	2004	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2004	only	-	Sep	21	0:00	0	-
-Rule	Iran	2005	only	-	Mar	22	0:00	1:00	-
-Rule	Iran	2005	only	-	Sep	22	0:00	0	-
-Rule	Iran	2008	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2008	only	-	Sep	21	0:00	0	-
-Rule	Iran	2009	2011	-	Mar	22	0:00	1:00	-
-Rule	Iran	2009	2011	-	Sep	22	0:00	0	-
-Rule	Iran	2012	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2012	only	-	Sep	21	0:00	0	-
-Rule	Iran	2013	2015	-	Mar	22	0:00	1:00	-
-Rule	Iran	2013	2015	-	Sep	22	0:00	0	-
-Rule	Iran	2016	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2016	only	-	Sep	21	0:00	0	-
-Rule	Iran	2017	2019	-	Mar	22	0:00	1:00	-
-Rule	Iran	2017	2019	-	Sep	22	0:00	0	-
-Rule	Iran	2020	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2020	only	-	Sep	21	0:00	0	-
-Rule	Iran	2021	2023	-	Mar	22	0:00	1:00	-
-Rule	Iran	2021	2023	-	Sep	22	0:00	0	-
-Rule	Iran	2024	only	-	Mar	21	0:00	1:00	-
-Rule	Iran	2024	only	-	Sep	21	0:00	0	-
-Rule	Iran	2025	2027	-	Mar	22	0:00	1:00	-
-Rule	Iran	2025	2027	-	Sep	22	0:00	0	-
-Rule	Iran	2028	2029	-	Mar	21	0:00	1:00	-
-Rule	Iran	2028	2029	-	Sep	21	0:00	0	-
-Rule	Iran	2030	2031	-	Mar	22	0:00	1:00	-
-Rule	Iran	2030	2031	-	Sep	22	0:00	0	-
-Rule	Iran	2032	2033	-	Mar	21	0:00	1:00	-
-Rule	Iran	2032	2033	-	Sep	21	0:00	0	-
-Rule	Iran	2034	2035	-	Mar	22	0:00	1:00	-
-Rule	Iran	2034	2035	-	Sep	22	0:00	0	-
-#
-# The following rules are approximations starting in the year 2038.
-# These are the best post-2037 approximations available, given the
-# restrictions of a single rule using a Gregorian-based data format.
+Rule	Iran	1978	1980	-	Mar	20	24:00	1:00	-
+Rule	Iran	1978	only	-	Oct	20	24:00	0	-
+Rule	Iran	1979	only	-	Sep	18	24:00	0	-
+Rule	Iran	1980	only	-	Sep	22	24:00	0	-
+Rule	Iran	1991	only	-	May	 2	24:00	1:00	-
+Rule	Iran	1992	1995	-	Mar	21	24:00	1:00	-
+Rule	Iran	1991	1995	-	Sep	21	24:00	0	-
+Rule	Iran	1996	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	1996	only	-	Sep	20	24:00	0	-
+Rule	Iran	1997	1999	-	Mar	21	24:00	1:00	-
+Rule	Iran	1997	1999	-	Sep	21	24:00	0	-
+Rule	Iran	2000	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2000	only	-	Sep	20	24:00	0	-
+Rule	Iran	2001	2003	-	Mar	21	24:00	1:00	-
+Rule	Iran	2001	2003	-	Sep	21	24:00	0	-
+Rule	Iran	2004	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2004	only	-	Sep	20	24:00	0	-
+Rule	Iran	2005	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2005	only	-	Sep	21	24:00	0	-
+Rule	Iran	2008	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2008	only	-	Sep	20	24:00	0	-
+Rule	Iran	2009	2011	-	Mar	21	24:00	1:00	-
+Rule	Iran	2009	2011	-	Sep	21	24:00	0	-
+Rule	Iran	2012	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2012	only	-	Sep	20	24:00	0	-
+Rule	Iran	2013	2015	-	Mar	21	24:00	1:00	-
+Rule	Iran	2013	2015	-	Sep	21	24:00	0	-
+Rule	Iran	2016	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2016	only	-	Sep	20	24:00	0	-
+Rule	Iran	2017	2019	-	Mar	21	24:00	1:00	-
+Rule	Iran	2017	2019	-	Sep	21	24:00	0	-
+Rule	Iran	2020	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2020	only	-	Sep	20	24:00	0	-
+Rule	Iran	2021	2023	-	Mar	21	24:00	1:00	-
+Rule	Iran	2021	2023	-	Sep	21	24:00	0	-
+Rule	Iran	2024	only	-	Mar	20	24:00	1:00	-
+Rule	Iran	2024	only	-	Sep	20	24:00	0	-
+Rule	Iran	2025	2027	-	Mar	21	24:00	1:00	-
+Rule	Iran	2025	2027	-	Sep	21	24:00	0	-
+Rule	Iran	2028	2029	-	Mar	20	24:00	1:00	-
+Rule	Iran	2028	2029	-	Sep	20	24:00	0	-
+Rule	Iran	2030	2031	-	Mar	21	24:00	1:00	-
+Rule	Iran	2030	2031	-	Sep	21	24:00	0	-
+Rule	Iran	2032	2033	-	Mar	20	24:00	1:00	-
+Rule	Iran	2032	2033	-	Sep	20	24:00	0	-
+Rule	Iran	2034	2035	-	Mar	21	24:00	1:00	-
+Rule	Iran	2034	2035	-	Sep	21	24:00	0	-
+Rule	Iran	2036	2037	-	Mar	20	24:00	1:00	-
+Rule	Iran	2036	2037	-	Sep	20	24:00	0	-
+Rule	Iran	2038	2039	-	Mar	21	24:00	1:00	-
+Rule	Iran	2038	2039	-	Sep	21	24:00	0	-
+Rule	Iran	2040	2041	-	Mar	20	24:00	1:00	-
+Rule	Iran	2040	2041	-	Sep	20	24:00	0	-
+Rule	Iran	2042	2043	-	Mar	21	24:00	1:00	-
+Rule	Iran	2042	2043	-	Sep	21	24:00	0	-
+Rule	Iran	2044	2045	-	Mar	20	24:00	1:00	-
+Rule	Iran	2044	2045	-	Sep	20	24:00	0	-
+Rule	Iran	2046	2047	-	Mar	21	24:00	1:00	-
+Rule	Iran	2046	2047	-	Sep	21	24:00	0	-
+Rule	Iran	2048	2049	-	Mar	20	24:00	1:00	-
+Rule	Iran	2048	2049	-	Sep	20	24:00	0	-
+Rule	Iran	2050	2051	-	Mar	21	24:00	1:00	-
+Rule	Iran	2050	2051	-	Sep	21	24:00	0	-
+Rule	Iran	2052	2053	-	Mar	20	24:00	1:00	-
+Rule	Iran	2052	2053	-	Sep	20	24:00	0	-
+Rule	Iran	2054	2055	-	Mar	21	24:00	1:00	-
+Rule	Iran	2054	2055	-	Sep	21	24:00	0	-
+Rule	Iran	2056	2057	-	Mar	20	24:00	1:00	-
+Rule	Iran	2056	2057	-	Sep	20	24:00	0	-
+Rule	Iran	2058	2059	-	Mar	21	24:00	1:00	-
+Rule	Iran	2058	2059	-	Sep	21	24:00	0	-
+Rule	Iran	2060	2062	-	Mar	20	24:00	1:00	-
+Rule	Iran	2060	2062	-	Sep	20	24:00	0	-
+Rule	Iran	2063	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2063	only	-	Sep	21	24:00	0	-
+Rule	Iran	2064	2066	-	Mar	20	24:00	1:00	-
+Rule	Iran	2064	2066	-	Sep	20	24:00	0	-
+Rule	Iran	2067	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2067	only	-	Sep	21	24:00	0	-
+Rule	Iran	2068	2070	-	Mar	20	24:00	1:00	-
+Rule	Iran	2068	2070	-	Sep	20	24:00	0	-
+Rule	Iran	2071	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2071	only	-	Sep	21	24:00	0	-
+Rule	Iran	2072	2074	-	Mar	20	24:00	1:00	-
+Rule	Iran	2072	2074	-	Sep	20	24:00	0	-
+Rule	Iran	2075	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2075	only	-	Sep	21	24:00	0	-
+Rule	Iran	2076	2078	-	Mar	20	24:00	1:00	-
+Rule	Iran	2076	2078	-	Sep	20	24:00	0	-
+Rule	Iran	2079	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2079	only	-	Sep	21	24:00	0	-
+Rule	Iran	2080	2082	-	Mar	20	24:00	1:00	-
+Rule	Iran	2080	2082	-	Sep	20	24:00	0	-
+Rule	Iran	2083	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2083	only	-	Sep	21	24:00	0	-
+Rule	Iran	2084	2086	-	Mar	20	24:00	1:00	-
+Rule	Iran	2084	2086	-	Sep	20	24:00	0	-
+Rule	Iran	2087	only	-	Mar	21	24:00	1:00	-
+Rule	Iran	2087	only	-	Sep	21	24:00	0	-
+#
+# The following rules are approximations starting in the year 2088.
+# These are the best post-2088 approximations available, given the
+# restrictions of a single rule using ordinary Gregorian dates.
 # At some point this table will need to be extended, though quite
 # possibly Iran will change the rules first.
-Rule	Iran	2036	max	-	Mar	21	0:00	1:00	-
-Rule	Iran	2036	max	-	Sep	21	0:00	0	-
+Rule	Iran	2088	max	-	Mar	20	24:00	1:00	-
+Rule	Iran	2088	max	-	Sep	20	24:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tehran	3:25:44	-	LMT	1916
-- 
2.17.1



More information about the tz mailing list