Skip to content

TYP: get_utcoffset #35107

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 6, 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/timezones.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cpython.datetime cimport tzinfo
from cpython.datetime cimport datetime, timedelta, tzinfo

cdef tzinfo utc_pytz

Expand All @@ -11,7 +11,7 @@ cpdef bint tz_compare(tzinfo start, tzinfo end)
cpdef object get_timezone(tzinfo tz)
cpdef object maybe_get_tz(object tz)

cdef get_utcoffset(tzinfo tz, obj)
cdef timedelta get_utcoffset(tzinfo tz, datetime obj)
cdef bint is_fixed_offset(tzinfo tz)

cdef object get_dst_info(tzinfo tz)
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/timezones.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import timezone
from cpython.datetime cimport datetime, tzinfo
from cpython.datetime cimport datetime, timedelta, tzinfo

# dateutil compat
from dateutil.tz import (
Expand Down Expand Up @@ -153,7 +153,7 @@ cdef inline object tz_cache_key(tzinfo tz):
# UTC Offsets


cdef get_utcoffset(tzinfo tz, obj):
cdef timedelta get_utcoffset(tzinfo tz, datetime obj):
try:
return tz._utcoffset
except AttributeError:
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import warnings

import numpy as np
from pytz import utc

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

def tz_convert(self, tz):
"""
Expand Down
5 changes: 2 additions & 3 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

from pandas._libs.algos import unique_deltas
from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs import Timestamp, tzconversion
from pandas._libs.tslibs.ccalendar import (
DAYS,
MONTH_ALIASES,
Expand All @@ -22,7 +22,6 @@
from pandas._libs.tslibs.parsing import get_rule_month
from pandas._libs.tslibs.resolution import month_position_check
from pandas._libs.tslibs.timezones import UTC
from pandas._libs.tslibs.tzconversion import tz_convert
from pandas.util._decorators import cache_readonly

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

self.warn = warn

Expand Down