-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
BUG/API: to_datetime preserves UTC offsets when parsing datetime strings #21822
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
Changes from 1 commit
ac5a3d1
b81a8e9
6bf46a8
678b337
1917148
581a33e
a1bc8f9
80042e6
7c4135e
0651416
bacb6e3
a2f4aad
d48f341
7efb25c
1d527ff
f89d6b6
d91c63f
1054e8b
d9cdc91
7d04613
031284c
749e62e
23cbf75
1e6f87a
7539bcf
c1f51cd
db75a24
4733ac5
e3db735
2fa681f
5f36c98
d7ff275
4ff7cb3
8463d91
dddc6b3
cca3983
e441be0
a8a65f7
75f9fd9
6052475
f916c69
807a251
1cbd9b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,8 +78,9 @@ def test_parsing_timezone_offsets(self, dt_string, expected_tz): | |
# All of these datetime strings with offsets are equivalent | ||
# to the same datetime after the timezone offset is added | ||
|
||
# TODO: Appears that the dateparser doesnt return offset info if string is non-ISO | ||
# maybe something in the np_datetime_strings parser is not catching this? | ||
# TODO: Appears that parsing non-ISO strings adjust the date to UTC | ||
# but don't return the offset. Not sure if this is the intended | ||
# behavior of non-iso strings in np_datetime_strings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np_datetime_strings doesn't handle non-ISO. That case ends up going through dateutil (via |
||
arr = np.array(['01-01-2013 00:00:00'], dtype=object) | ||
expected = tslib.array_to_datetime(arr)[0] | ||
|
||
|
@@ -89,11 +90,14 @@ def test_parsing_timezone_offsets(self, dt_string, expected_tz): | |
assert result_tz is expected_tz | ||
|
||
def test_parsing_different_timezone_offsets(self): | ||
#GH 17697 | ||
# GH 17697 | ||
data = ["2015-11-18 15:30:00+05:30", "2015-11-18 15:30:00+06:30"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have these same tests using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
result, result_tz = tslib.array_to_datetime(np.array(data, dtype=object)) | ||
expected = np.array([datetime(2015, 11, 18, 15, 30, tzinfo=tzoffset(None, 19800)), | ||
datetime(2015, 11, 18, 15, 30, tzinfo=tzoffset(None, 23400))], | ||
data = np.array(data, dtype=object) | ||
result, result_tz = tslib.array_to_datetime(data) | ||
expected = np.array([datetime(2015, 11, 18, 15, 30, | ||
tzinfo=tzoffset(None, 19800)), | ||
datetime(2015, 11, 18, 15, 30, | ||
tzinfo=tzoffset(None, 23400))], | ||
dtype=object) | ||
tm.assert_numpy_array_equal(result, expected) | ||
assert result_tz is None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case with multiple tzs that has to get wrapped in object-dtype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That case will result in
tz_parsed = None
so this branch will not be hit.