Consider the following example, where I take a naive datetime, make it timezone aware in UTC, and then convert to UTC-5:
d1 = datetime.datetime(2019,3,7, 7,45)
d2 = pytz.utc.localize(d1)
print(f'UTC : {d2}')
d3 = d2.astimezone(pytz.timezone('Etc/GMT-5'))
print(f'UTC-5: {d3}')
The output of this is:
UTC : 2019-03-07 07:45:00+00:00 UTC-5: 2019-03-07 12:45:00+05:00
I would have expected the UTC-5
time to be 02:45
, but the 5 hour offset is being added to UTC, rather than subtracted.
Questions:
- Why is the
'Etc/GMT-5'
offset applied to UTC +5 hours instead of -5 hours? - How can I convert from
UTC
toUTC-5
?