[Datetime-SIG] Making dt parameter of timezone.tzname(dt) optional
Tim Peters
tim.peters at gmail.com
Wed Sep 9 19:58:54 CEST 2015
[Tim]
>> +0. The base (tzinfo) class requires the datetime argument because,
>> in general, a zone's name depends on the datetime (like "is it in the
>> zone's "daylight" time"?).
[Alex]
> I was thinking of returning the "zoneinfo" name such as America/New_York in
> this case. This would end the debate about what is the "proper" timezone
> name: if you know the date and time - you can get a specific EST/EDT
> abbreviation. If not - you'll just get whatever the zoneinfo calls itself.
That's fine, and even desirable ;-)
Just saying it's too late to change that the _base_ trzinfo class has
always had a documented requirement for a datetime argument to
tzinfo.tzname(). General code slinging trzinfos can only assume
what's promised, and must supply what's required, by the base class.
Subclasses are free to promise more (but not less) and/or require less
(but not more), and code is free to rely on that, but such code is no
longer general.
Since that's just a _potential_ problem, and Python is for consenting
adults, +0 on the original proposal (doesn't really matter to me
either way, but I have a mild preference for allowing a simplification
("require less") in the `timezone` subclass).
More information about the Datetime-SIG
mailing list