Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
"""
Convert the val (in i8) from timezone1 to timezone2

This is a single timezone versoin of tz_convert
This is a single timezone version of tz_convert

Parameters
----------
Expand All @@ -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

Expand All @@ -444,8 +447,8 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):

if get_timezone(tz2) == 'UTC':
return utc_date
Copy link
Contributor

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)

if is_tzlocal(tz2):
dt64_to_dtstruct(val, &dts)
elif is_tzlocal(tz2):
dt64_to_dtstruct(utc_date, &dts)
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
Expand Down