[Datetime-SIG] PEP-495 - Strict Invalid Time Checking

Akira Li 4kir4.1i at gmail.com
Wed Aug 26 01:24:03 CEST 2015

Alexander Belopolsky <alexander.belopolsky at gmail.com> writes:

> On Tue, Aug 25, 2015 at 1:56 PM, Stuart Bishop <stuart at stuartbishop.net>
> wrote:
>> What would be even nicer is if users didn't have to use localize at all:
>> >> datetime.now(tz=pytz.timezone('US/Eastern'))
> This is certainly one of the main goals of PEP 495.  Note that
> datetime.now() will never produce an invalid datetime and will always set
> the fold attribute correctly in the (two-)fold case if
> pytz.timezone('US/Eastern') follows PEP guidelines.  Therefore there is no
> need for the third fold value in this case.

datetime.now(pytz.timezone('US/Eastern')) already works [1]
It doesn't require the disambiguation flag for pytz timezones. Though the flag might
be useful for dateutil timezones:  datetime.now(dateutil.tz.tzlocal()) may
fail [2]

[1] http://stackoverflow.com/questions/31886808/when-does-datetime-nowpytz-timezone-fail
[2] https://github.com/dateutil/dateutil/issues/57

More information about the Datetime-SIG mailing list