replace interface is not correct for 'Asia/Kolkata'
antonguzun opened this issue · 1 comments
antonguzun commented
By example +5:53:00:
import pytz
import datetime
datetime.datetime.now().replace(tzinfo=pytz.timezone('Asia/Kolkata')).tzinfo
<DstTzInfo 'Asia/Kolkata' LMT+5:53:00 STD>
This value has been irrelevant since Oct. 1941 https://www.wikinone.com/Time_in_India.html
I expect +5:30:00:
import pytz
import datetime
pytz.timezone('Asia/Kolkata').localize(datetime.datetime.now()).tzinfo
<DstTzInfo 'Asia/Kolkata' IST+5:30:00 STD>
stub42 commented
Yes, the replace interface will not work with pytz per https://github.com/stub42/pytz/blob/master/src/README.rst#localized-times-and-date-arithmetic . pytz.timezone('Asia/Kolkata') doesn't know when the timezone needs to be set to, and you get the first. localize() adds that context.