Skip to content

Commit 1d26e3a

Browse files
authored
TYP: get_utcoffset (#35107)
1 parent 7e9f66e commit 1d26e3a

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

pandas/_libs/tslibs/timezones.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cpython.datetime cimport tzinfo
1+
from cpython.datetime cimport datetime, timedelta, tzinfo
22

33
cdef tzinfo utc_pytz
44

@@ -11,7 +11,7 @@ cpdef bint tz_compare(tzinfo start, tzinfo end)
1111
cpdef object get_timezone(tzinfo tz)
1212
cpdef object maybe_get_tz(object tz)
1313

14-
cdef get_utcoffset(tzinfo tz, obj)
14+
cdef timedelta get_utcoffset(tzinfo tz, datetime obj)
1515
cdef bint is_fixed_offset(tzinfo tz)
1616

1717
cdef object get_dst_info(tzinfo tz)

pandas/_libs/tslibs/timezones.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import timezone
2-
from cpython.datetime cimport datetime, tzinfo
2+
from cpython.datetime cimport datetime, timedelta, tzinfo
33

44
# dateutil compat
55
from dateutil.tz import (
@@ -153,7 +153,7 @@ cdef inline object tz_cache_key(tzinfo tz):
153153
# UTC Offsets
154154

155155

156-
cdef get_utcoffset(tzinfo tz, obj):
156+
cdef timedelta get_utcoffset(tzinfo tz, datetime obj):
157157
try:
158158
return tz._utcoffset
159159
except AttributeError:

pandas/core/arrays/datetimes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import warnings
44

55
import numpy as np
6-
from pytz import utc
76

87
from pandas._libs import lib, tslib
98
from pandas._libs.tslibs import (
@@ -725,7 +724,7 @@ def _local_timestamps(self):
725724
This is used to calculate time-of-day information as if the timestamps
726725
were timezone-naive.
727726
"""
728-
return tzconversion.tz_convert(self.asi8, utc, self.tz)
727+
return tzconversion.tz_convert(self.asi8, timezones.UTC, self.tz)
729728

730729
def tz_convert(self, tz):
731730
"""

pandas/tseries/frequencies.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55

66
from pandas._libs.algos import unique_deltas
7-
from pandas._libs.tslibs import Timestamp
7+
from pandas._libs.tslibs import Timestamp, tzconversion
88
from pandas._libs.tslibs.ccalendar import (
99
DAYS,
1010
MONTH_ALIASES,
@@ -22,7 +22,6 @@
2222
from pandas._libs.tslibs.parsing import get_rule_month
2323
from pandas._libs.tslibs.resolution import month_position_check
2424
from pandas._libs.tslibs.timezones import UTC
25-
from pandas._libs.tslibs.tzconversion import tz_convert
2625
from pandas.util._decorators import cache_readonly
2726

2827
from pandas.core.dtypes.common import (
@@ -199,7 +198,7 @@ def __init__(self, index, warn: bool = True):
199198
# the timezone so they are in local time
200199
if hasattr(index, "tz"):
201200
if index.tz is not None:
202-
self.i8values = tz_convert(self.i8values, UTC, index.tz)
201+
self.i8values = tzconversion.tz_convert(self.i8values, UTC, index.tz)
203202

204203
self.warn = warn
205204

0 commit comments

Comments
 (0)