Is normalize still needed when converting to local time zones?
pytz's documentation contains this example when explaining that you need to use normalize() when converting to local time:
>>> utc_dt = utc.localize(
>>> utc_dt.
'2006-03-26 21:34:59 UTC+0000'
>>> au_tz = timezone(
>>> au_dt = au_tz.normalize
>>> au_dt.strftime(fmt)
'2006-03-27 08:34:59 EST+1100'
However, if I don't use normalize(), I get the same result:
>>> utc_dt.
'2006-03-27 08:34:59 EST+1100'
normalize() is definitely still needed when doing arithmetic on local times, but I'm wondering if the code has changed over the years such that normalize() is no longer needed when merely converting to local time? It seems like pytz's fromutc() method has an opportunity to attach the correct tzinfo instance within astimezone(), such that normalize() afterwards wouldn't be necessary.
If normalize() is still needed, I would very much appreciate an example showing when it's necessary, so that I can include it in a write-up I'm doing of handling time zones in Python.
Thank you very much, and thank you for pytz!
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- pytz Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: