|
|
|
|
|
by deepsun
2586 days ago
|
|
> pytz.timezone('America/New_York').localize(
datetime(2019, 5, 21, 12, 30)) But wait, the datetime argument doesn't specify exact time instance, because it's "zone-less" itself! So the above code can also be buggy/unclear, if instead of 2019 we'd use a datetime close to the switch time. We should provide a time zone to the datetime param as well. Better GMT, otherwise we would need to localize that one as well, falling into an infinite loop. |
|
The pytz docs are pretty much on-point, too:
> "The preferred way of dealing with times is to always work in UTC, converting to localtime only when generating output to be read by humans."
This, also, is the problem with this article, and is a really common pain-point across the spectrum of programmers, both new and seasoned.