[Python-Dev] Draft PEP for time zone support.

Steven D'Aprano steve at pearwood.info
Sun Dec 30 11:19:54 CET 2012


On 29/12/12 15:40, Lennart Regebro wrote:
> On Sat, Dec 29, 2012 at 2:23 AM, Steven D'Aprano<steve at pearwood.info>wrote:
>
>> The PEP says:
>>
>> * New function :``timezone(name=None, db_path=None)``
>>
>>
>>    This function takes a name string that must be a string specifying a
>>    valid zoneinfo timezone, ie "US/Eastern", "Europe/Warsaw" or
>> "Etc/GMT+11".
>>
>>
>> It isn't 100% clear to me from the PEP what a valid name string would be,
>> but I assume that it will accept anything that the time.tzset function
>> will accept:
>>
>
> No, valid names are the names of time zones in the zoneinfo database.


If I've understood it correctly, that contradicts the PEP. One example
given is "Etc/GMT+11", which is not a timezone *name*, but a timezone
name *plus an offset*. Presumably if GMT+11 is legal, so should be
GMT+10:30.

There is no "Etc/GMT+11" named here:

http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

nor is it included in /usr/share/zoneinfo/zone.tab in either of the systems
I looked at (one Debian, one Centos), but there is Etc/GMT. So I conclude
that the PEP allows timezone rules, not just names.

Either way, I think the PEP needs to clarify what counts as a valid name
string.



> There
> isn't really any usecase for defining up your own rules as that would mean
> that you want a time zone that doesn't exist, which seems a bit pointless.
> :-)

It means you want a time zone that doesn't exist in the database, which is
not the same as not existing in real life.

Perhaps the database is out-of-date, or the government has suddenly declared
a daylight savings change that isn't reflected yet in the database. Or you
want to set your own TZ rules for testing. Or you've just declared independence
from the central government and are setting up your own TZ rules.

time.tzset supports rules as well as names. Is there some reason why this
module should not do the same?

I also quote from /usr/share/doc/tzdata-2012f/README on my Centos system:

[quote]
README for the tz distribution
[...]

The 1989 update of the time zone package featured
[...]
*       reference data from the United States Naval Observatory for folks who
         want to do additional time zones
[end quote]


So the people who prepare tzdata on Red Hat systems clearly think that there
are use-cases for making additional time zones.



-- 
Steven


More information about the Python-Dev mailing list