-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pd.to_datetime("2015-11-18 15:30:00+05:30").tz_localize('UTC').tz_convert('Asia/Kolkata') returns '2015-11-18 16:30:00+0530' #11708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
pls show your versions of pytz and dateutil |
I am using Python 3.4.3 pytz Version:- 2015.7 dateutil version :- 2.4.2 |
This is somewhat similar to #11481. As you see below, the tzinfo.utcoffset gets intepreted as 4:30 (I put in print statements to help debug) and so your subsequent operations are off. This is a bug as far as I'm concerned.
|
And notice that if I remove the "0" in front of the offset, it works correctly as it goes into the dateutil parser (again the extra output is for debugging purposes).
|
Please note that "o" in time stamp was returned by Pandas only. For details refer below code.
|
Needs to look more, but the below line looks problematic. After the change, we get:
|
I agree that does look suspicious and that you should be adding and not subtracting. I guess we have no tests with a tzoffset that contains minutes? |
Further confirmed with an even better example: With subtraction:
With addition:
I'll open up a PR. |
TST: more tests, xref pandas-dev#15823, xref pandas-dev#11708
running "pd.to_datetime("2015-11-18 15:30:00+05:30").tz_localize('UTC').tz_convert('Asia/Kolkata')" returns following o/p
Timestamp('2015-11-18 16:30:00+0530', tz='Asia/Kolkata')
It should have returned as Timestamp('2015-11-18 15:30:00+0530', tz='Asia/Kolkata') as no daylight saving is applicable in India.
The text was updated successfully, but these errors were encountered: