pytz localize vs datetime replace

localize just assumes that the naive datetime you pass it is “right” (except for not knowing about the timezone!) and so just sets the timezone, no other adjustments.

You can (and it’s advisable…) internally work in UTC (rather than with naive datetimes) and use replace when you need to perform I/O of datetimes in a localized way (normalize will handle DST and the like).

Leave a Comment