Skip to content

CLN: remove unnecessary get_timezone calls #35071

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

Merged
merged 2 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from pandas._libs.tslibs.util cimport (

from pandas._libs.tslibs.timezones cimport (
is_utc, is_tzlocal, is_fixed_offset, get_utcoffset, get_dst_info,
get_timezone, maybe_get_tz, tz_compare,
maybe_get_tz, tz_compare,
utc_pytz as UTC,
)
from pandas._libs.tslibs.parsing import parse_datetime_string
Expand Down Expand Up @@ -267,7 +267,7 @@ def datetime_to_datetime64(ndarray[object] values):
if not tz_compare(val.tzinfo, inferred_tz):
raise ValueError('Array must be all same time zone')
else:
inferred_tz = get_timezone(val.tzinfo)
inferred_tz = val.tzinfo

_ts = convert_datetime_to_tsobject(val, None)
iresult[i] = _ts.value
Expand Down
7 changes: 3 additions & 4 deletions pandas/_libs/tslibs/tzconversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ from pandas._libs.tslibs.ccalendar cimport DAY_NANOS, HOUR_NANOS
from pandas._libs.tslibs.nattype cimport NPY_NAT
from pandas._libs.tslibs.np_datetime cimport (
npy_datetimestruct, dt64_to_dtstruct)
from pandas._libs.tslibs.timezones cimport (
get_dst_info, is_tzlocal, is_utc, get_timezone)
from pandas._libs.tslibs.timezones cimport get_dst_info, is_tzlocal, is_utc


# TODO: cdef scalar version to call from convert_str_to_tsobject
Expand Down Expand Up @@ -358,13 +357,13 @@ cpdef int64_t tz_convert_single(int64_t val, tzinfo tz1, tzinfo tz2):
# Convert to UTC
if is_tzlocal(tz1):
utc_date = _tz_convert_tzlocal_utc(val, tz1, to_utc=True)
elif not is_utc(get_timezone(tz1)):
elif not is_utc(tz1):
arr[0] = val
utc_date = _tz_convert_dst(arr, tz1, to_utc=True)[0]
else:
utc_date = val

if is_utc(get_timezone(tz2)):
if is_utc(tz2):
return utc_date
elif is_tzlocal(tz2):
return _tz_convert_tzlocal_utc(utc_date, tz2, to_utc=False)
Expand Down