Somehow it seems to be related to the timezone itself. Just like pytc.utc
is different to 'Europe/London'
, in this case 'America/New_York'
is not the same as 'US/Eastern'
.
newDt = dt.replace(year=2019, month=7, day=23) #2019-07-23 16:00:00-05:00
newDt.astimezone(pytz.timezone('US/Eastern')) #2019-07-23 17:00:00-04:00
However, according to Wikipedia they should behave the exact same way.
CORRECTION
My answer above does not seem to be right.
Apparently the issue seems to be related to some odd behavior from the replace
function, where it does not carry the dst information if the original date was not during the daylight saving period. Some people have mentioned it here.
You would need to re-localize that date using astimezone
print (newDt.astimezone(pytz.timezone('America/New_York')))
Out[14]:
2019-07-23 17:00:00-04:00