Skip to content

Commit f968883

Browse files
authored
CLN: remove unnecessary get_timezone calls (#35071)
1 parent de82b5e commit f968883

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

pandas/_libs/tslibs/conversion.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ from pandas._libs.tslibs.util cimport (
2727

2828
from pandas._libs.tslibs.timezones cimport (
2929
is_utc, is_tzlocal, is_fixed_offset, get_utcoffset, get_dst_info,
30-
get_timezone, maybe_get_tz, tz_compare,
30+
maybe_get_tz, tz_compare,
3131
utc_pytz as UTC,
3232
)
3333
from pandas._libs.tslibs.parsing import parse_datetime_string
@@ -267,7 +267,7 @@ def datetime_to_datetime64(ndarray[object] values):
267267
if not tz_compare(val.tzinfo, inferred_tz):
268268
raise ValueError('Array must be all same time zone')
269269
else:
270-
inferred_tz = get_timezone(val.tzinfo)
270+
inferred_tz = val.tzinfo
271271

272272
_ts = convert_datetime_to_tsobject(val, None)
273273
iresult[i] = _ts.value

pandas/_libs/tslibs/tzconversion.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ from pandas._libs.tslibs.ccalendar cimport DAY_NANOS, HOUR_NANOS
2020
from pandas._libs.tslibs.nattype cimport NPY_NAT
2121
from pandas._libs.tslibs.np_datetime cimport (
2222
npy_datetimestruct, dt64_to_dtstruct)
23-
from pandas._libs.tslibs.timezones cimport (
24-
get_dst_info, is_tzlocal, is_utc, get_timezone)
23+
from pandas._libs.tslibs.timezones cimport get_dst_info, is_tzlocal, is_utc
2524

2625

2726
# TODO: cdef scalar version to call from convert_str_to_tsobject
@@ -358,13 +357,13 @@ cpdef int64_t tz_convert_single(int64_t val, tzinfo tz1, tzinfo tz2):
358357
# Convert to UTC
359358
if is_tzlocal(tz1):
360359
utc_date = _tz_convert_tzlocal_utc(val, tz1, to_utc=True)
361-
elif not is_utc(get_timezone(tz1)):
360+
elif not is_utc(tz1):
362361
arr[0] = val
363362
utc_date = _tz_convert_dst(arr, tz1, to_utc=True)[0]
364363
else:
365364
utc_date = val
366365

367-
if is_utc(get_timezone(tz2)):
366+
if is_utc(tz2):
368367
return utc_date
369368
elif is_tzlocal(tz2):
370369
return _tz_convert_tzlocal_utc(utc_date, tz2, to_utc=False)

0 commit comments

Comments
 (0)