Closed cfchou closed 8 years ago
See the pytz guide, specifically in this section it says:
You can take shortcuts when dealing with the UTC side of timezone conversions. normalize() and localize() are not really necessary when there are no daylight saving time transitions to deal with.
So in this example, if the other timezone was not UTC, then you'd need both astimezone
(to convert timezones) and normalize
(to make sure you account for daylight savings time).
p.165 there's a snippet demonstrating pytz:
I don't quite understand this line
utc_dt = pytz.utc.normalize(nyc_dt.astimezone(pytz.utc))
. Which seems to me tries to convert to utc datetime twice.I tried
utc_dt = pytz.utc.normalize(nyc_dt)
and I feel that's sufficient unless I miss something.