I am doing some "software archaeology" on python-dateutil
to fully document (and tighten up) the formats accepted by dateutil.tz.tzstr
, and I have come across a strange timezone format that is obviously intended to be explicitly supported (link goes to the code):
# GMT0BST,3,0,30,3600,10,0,26,7200[,3600]
Just reading the code, I've figured out how it works. It starts out like a TZ
environment variable:
GMT
: Standard time abbreviation0
: Standard offset (in hours)BST
: DST abbreviationThen the rest is a comma-delimited list, broken into two parts:
3,0,30,3600
: DST->STD transition time specifier - month, week of month, day of week, seconds after midnight that the transition happens (note that when "week of month" is 0, the number following is actually the day of the month)10,0,26,7200
: STD->DST transition time specifier - same as above[,3600]
: If specified, this says how big the offset is during DST (default is 1 hour)The GNU TZ
variable equivalent to this string is GMT0BST,J89/1,J299/2
:
>>> from dateutil import tz
>>> tz1 = tz.tzstr('GMT0BST,3,0,30,3600,10,0,26,7200')
>>> tz2 = tz.tzstr('GMT0BST,J89/1,J299/2')
>>> tz1 == tz2
True
Is this a standard timezone format somewhere, or just something that one of the earlier maintainers of dateutil
added? It seems somewhat strange to add a custom time zone format that expresses exactly the same thing a GNU TZ
variable does, but I only ever see "IANA database" and "POSIX TZ variable" as formats when searching for time zone rules.
No, that's not a standard format of any kind (AFAIK). Must be something internal to dateutil.
Note that this appears to be for Europe/London
, and the correct POSIX string (for current years) would be GMT0BST,M3.3.0/1,M10.5.0