-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Assert at least one tz arg is always UTC #18228
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 4 commits
81f8a33
65f001d
563510c
359aeff
17dd7ab
c1aa846
754dd7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -422,6 +422,9 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2): | |
pandas_datetimestruct dts | ||
datetime dt | ||
|
||
# See GH#17734 We should always be converting either from UTC or to UTC | ||
assert (is_utc(tz1) or tz1 == 'UTC') or (is_utc(tz2) or tz2 == 'UTC') | ||
|
||
if val == NPY_NAT: | ||
return val | ||
|
||
|
@@ -445,7 +448,7 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2): | |
if get_timezone(tz2) == 'UTC': | ||
return utc_date | ||
if is_tzlocal(tz2): | ||
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. elif |
||
dt64_to_dtstruct(val, &dts) | ||
dt64_to_dtstruct(utc_date, &dts) | ||
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. huh? this seems like it would break something, if it doesn't that's a problem 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. The bug here is an inconsistency between tz_convert and tz_convert_single. The edit here makes tz_convert_single behave the same as tz_convert. The reason why this hasn't broken anything is because in all existing usages+tests of tz_convert_single, one of Of course, assuming the tz_convert implementation is correct, once the implementation here is changed, the assertion is no longer necessary. 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. I think one of my comments is gone. remove the first clause else (which just sets |
||
dt = datetime(dts.year, dts.month, dts.day, dts.hour, | ||
dts.min, dts.sec, dts.us, tz2) | ||
delta = int(get_utcoffset(tz2, dt).total_seconds()) * 1000000000 | ||
|
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.
return val (see my comment below)