pytz and Python timezones
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Sat Jun 11 08:24:37 EDT 2016
On 11-6-2016 13:37, Johannes Bauer wrote:
> Hi there,
> first off, let me admit that I have a hard time comprehensively wrapping
> my head around timezones. Everything around them is much more
> complicated than it seems, IMO.
They might not seem complicated, but actually they are. Mindbogglingly so:
> Gives me the expected result of:
> datetime.datetime(2016, 1, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Berlin'
> CET+1:00:00 STD>)
> Can someone explain what's going on here and why I end up with the weird
> "00:53" timezone? Is this a bug or am I doing things wrong?
I ran into the same issue a while ago and have since accepted that "the right way to do
it" is indeed not passing a tzinfo into the datetime constructor, but to always use the
second form with tz.localize(datetime).
I suppose it is a problem (not so much a bug) caused by the way timezones are done
internally in pytz and/or datetime but haven't looked into the details. Mostly because
of what is said the video I linked above :)
More information about the Python-list