On Sat, Aug 22, 2015 at 5:35 PM, Chris Barker <[email protected]> wrote:
> Do pytz or datetutils let you construct a tzinfo instance from "EST" or
> the like?
>
> (if the answer is no -- no need to drag the thread out...)
You can discuss this on pytz or dateutils mailing lists. The issue that I
find relevant for this group is the question I now replaced the subject
with: Is EDT a timezone?
The answer provided by python 3.3 and later is unequivocal "yes":
>>> from datetime import *
>>> u = datetime.now(timezone.utc)
>>> t = u.astimezone()
>>> t.tzname()
'EDT'
>>> isinstance(t.tzinfo, timezone)
True
>>> print(t.tzinfo)
EDT
Some people on this list claimed that the following behavior is a bug:
>>> (t + timedelta(100)).strftime('%F %T %Z%z')
'2015-11-30 17:45:51 EDT-0400'
because the correct result should be '2015-11-30 16:45:51 EST-0500'.
My answer to that is that if you need that result, you can get it, but you
have to ask for it explicitly:
>>> (t + timedelta(100)).astimezone().strftime('%F %T %Z%z')
'2015-11-30 16:45:51 EST-0500'
I don't think we can do much here other than to educate Python users.
_______________________________________________
Datetime-SIG mailing list
[email protected]
https://mail.python.org/mailman/listinfo/datetime-sig
The PSF Code of Conduct applies to this mailing list:
https://www.python.org/psf/codeofconduct/