[Tzdist] Fun with tzdata and non-Gregorian DST rules

Ken Murchison <murch@andrew.cmu.edu> Fri, 13 November 2015 18:50 UTC

Return-Path: <murch@andrew.cmu.edu>
X-Original-To: tzdist@ietfa.amsl.com
Delivered-To: tzdist@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 403331B2E73 for <tzdist@ietfa.amsl.com>; Fri, 13 Nov 2015 10:50:59 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.509
X-Spam-Level:
X-Spam-Status: No, score=-1.509 tagged_above=-999 required=5 tests=[BAYES_50=0.8, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jyZ_dQEc7P4X for <tzdist@ietfa.amsl.com>; Fri, 13 Nov 2015 10:50:57 -0800 (PST)
Received: from smtp.andrew.cmu.edu (SMTP.ANDREW.CMU.EDU [128.2.157.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id ED70B1B2E67 for <tzdist@ietf.org>; Fri, 13 Nov 2015 10:50:56 -0800 (PST)
Received: from localhost.localdomain (cpe-76-180-151-43.buffalo.res.rr.com [76.180.151.43]) (user=murch mech=PLAIN (0 bits)) by smtp.andrew.cmu.edu (8.14.8/8.14.8) with ESMTP id tADIos80018021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <tzdist@ietf.org>; Fri, 13 Nov 2015 13:50:54 -0500
Message-ID: <5646310E.8050503@andrew.cmu.edu>
Date: Fri, 13 Nov 2015 13:50:54 -0500
From: Ken Murchison <murch@andrew.cmu.edu>
Organization: Carnegie Mellon University
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version: 1.0
To: Time Zone Data Distribution Service <tzdist@ietf.org>
Content-Type: multipart/alternative; boundary="------------060003020202090603050407"
X-PMX-Version: 6.0.3.2322014, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.11.13.184517
X-SMTP-Spam-Clean: 27% ( SXL_IP_DYNAMIC 3, BODYTEXTH_SIZE_10000_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, RDNS_GENERIC_POOLED 0, RDNS_POOLED 0, RDNS_RESIDENTIAL 0, RDNS_SUSP 0, RDNS_SUSP_GENERIC 0, RDNS_SUSP_SPECIFIC 0, __ANY_URI 0, __BAT_BOUNDARY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HTML_AHREF_TAG 0, __HTTPS_URI 0, __INT_PROD_LOC 0, __MIME_HTML 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __MULTIPLE_URI_HTML 0, __MULTIPLE_URI_TEXT 0, __RDNS_POOLED_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TAG_EXISTS_HTML 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_MAILTO 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0)
X-SMTP-Spam-Score: 27%
X-Scanned-By: MIMEDefang 2.74 on 128.2.157.38
Archived-At: <http://mailarchive.ietf.org/arch/msg/tzdist/uo3KW_jfoUW6rFOO1-pkAzPs3IM>
Subject: [Tzdist] Fun with tzdata and non-Gregorian DST rules
X-BeenThere: tzdist@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <tzdist.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tzdist>, <mailto:tzdist-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tzdist/>
List-Post: <mailto:tzdist@ietf.org>
List-Help: <mailto:tzdist-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tzdist>, <mailto:tzdist-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 13 Nov 2015 18:50:59 -0000

All,

I found this interesting/amusing so I thought I'd share it.

I was poking around tzdata trying to figure out why Asia/Tehran compiled 
with vzic doesn't include a POSIX tz string and I found out that its 
because the Iranian DST rules are based on the Persian calendar, not the 
Gregorian calendar.  This is why the Rule for Iran has a list of changes 
in groups of 1-3 years up to 2038 and no Rule that extends out into the 
future.

As can be expected, an iCalendar representation for Asia/Tehran based on 
tzdata also has a list of dates and no recurrence rule that repeats forever.

However, a much more compact iCalendar representation for this zone that 
does extend to eternity can be created using Non-Gregoran Recurrence 
Rules in iCalendar <https://tools.ietf.org/html/rfc7529> (RSCALE).

I created a new zone named Asia/Tehran_Persian using the RSCALE 
extension and installed it on my tzdist test server.

For those that are interested, you can look at the 2 zones here:

https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran
https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran_Persian

If you want to compare the observances, especially those from 1991-2038 
(yes, they match), you can view them here in JSON format:

https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran/observances?start=0000-01-01T00:00:00Z&end=2500-01-01T00:00:00Z
https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran_Persian/observances?start=0000-01-01T00:00:00Z&end=2500-01-01T00:00:00Z

and here in "zdump -V" format:

https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran/observances?start=0000-01-01T00:00:00Z&end=2500-01-01T00:00:00Z&format=application/zdump
https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran_Persian/observances?start=0000-01-01T00:00:00Z&end=2500-01-01T00:00:00Z&format=application/zdump

For those that are really ambitious, you can look at a binary "tzfile" 
version of Asia/Tehran_Persian (which gets created from the iCalendar 
data) here:

https://cyrus-test.andrew.cmu.edu/tzdist/zones/Asia/Tehran_Persian?format=application/tzfile

This file is binary compatible with one created by vzic except I don't 
add a transition at 2440-01-01 like vzic does.  (I'm not even sure why 
that transition is there or what it means).


I briefly looked for other zones based on lunisolar calendars and didn't 
come up with any.  The Brazilian rules are essentially based around 
Easter and there is no way that I have found to represent Easter as a 
recurrence rule in iCalendar.

All of this is just for fun at this point because I don't believe that 
any calendaring clients have support for RSCALE yet.

-- 
Kenneth Murchison
Principal Systems Software Engineer
Carnegie Mellon University