Re: [Datetime-SIG] PEP-495 - Strict Invalid Time Checking
Alexander Belopolsky
On Tue, Aug 25, 2015 at 1:56 PM, Stuart Bishop
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-timez... [2] https://github.com/dateutil/dateutil/issues/57
participants (1)
-
Akira Li