Ho problemi a capire la conversione tra il fuso orario "Etc/GMT-5" e l'UTC in pytz.pytz e Etc/GMT-5
>>> dt = datetime(2009, 9, 9, 10, 0) # September 9 2009, 10:00
>>> gmt_5 = pytz.timezone("Etc/GMT-5")
>>> gmt_5.localize(dt)
datetime.datetime(2009, 9, 9, 10, 0, tzinfo=<StaticTzInfo 'Etc/GMT-5'>)
Tutto va bene fino ad ora, ma poi cerco di convertire in UTC:
>>> gmt_5.localize(dt).astimezone(pytz.utc)
datetime.datetime(2009, 9, 9, 5, 0, tzinfo=<UTC>)
Quindi a me sembra che durante la conversione dalle 10:00 in GMT-5 a UTC ottengo 05:00? Mi aspetterei che pytz mi dia 15:00 invece.
Cosa mi manca?
EDIT: mi hanno confermato che la conversione fuso orario per il fuso orario US/Eastern funziona altrettanto mi aspetto:
>>> eastern = pytz.timezone("US/Eastern")
>>> eastern.localize(dt)
datetime.datetime(2009, 9, 9, 10, 0, tzinfo=...) # Too long
>>> pytz.utc.normalize(eastern.localize(dt).astimezone(pytz.utc))
datetime.datetime(2009, 9, 9, 14, 0, tzinfo=<UTC>)
EDIT 2: mi hanno confermato che quando uso Etc/GMT +5 Prendo 15:00, che è quello che mi aspetterei di ottenere da Etc/GMT-5. È un bug di pytz?
Hai battuto la mia risposta di 23 secondi! :) –