Skip to content

De-privatize timezone funcs #17502

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 4 commits into from
Sep 13, 2017
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
6 changes: 3 additions & 3 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cimport tslib

from hashtable cimport HashTable

from tslibs.timezones cimport _is_utc
from tslibs.timezones cimport is_utc, get_utcoffset
from pandas._libs import tslib, algos, hashtable as _hash
from pandas._libs.tslib import Timestamp, Timedelta
from datetime import datetime, timedelta
Expand Down Expand Up @@ -551,8 +551,8 @@ cdef inline _to_i8(object val):
tzinfo = getattr(val, 'tzinfo', None)
# Save the original date value so we can get the utcoffset from it.
ival = _pydatetime_to_dts(val, &dts)
if tzinfo is not None and not _is_utc(tzinfo):
offset = tslib._get_utcoffset(tzinfo, val)
if tzinfo is not None and not is_utc(tzinfo):
offset = get_utcoffset(tzinfo, val)
ival -= tslib._delta_to_nanoseconds(offset)
return ival
return val
Expand Down
14 changes: 7 additions & 7 deletions pandas/_libs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from lib cimport is_null_datetimelike, is_period
from pandas._libs import tslib, lib
from pandas._libs.tslib import (Timedelta, Timestamp, iNaT,
NaT)
from tslibs.timezones cimport _is_utc, _is_tzlocal, _get_utcoffset
from tslibs.timezones cimport is_utc, is_tzlocal, get_utcoffset
from tslib cimport (
maybe_get_tz,
_get_dst_info,
Expand Down Expand Up @@ -533,23 +533,23 @@ cdef _reso_local(ndarray[int64_t] stamps, object tz):
ndarray[int64_t] trans, deltas, pos
pandas_datetimestruct dts

if _is_utc(tz):
if is_utc(tz):
for i in range(n):
if stamps[i] == NPY_NAT:
continue
pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns, &dts)
curr_reso = _reso_stamp(&dts)
if curr_reso < reso:
reso = curr_reso
elif _is_tzlocal(tz):
elif is_tzlocal(tz):
for i in range(n):
if stamps[i] == NPY_NAT:
continue
pandas_datetime_to_datetimestruct(stamps[i], PANDAS_FR_ns,
&dts)
dt = datetime(dts.year, dts.month, dts.day, dts.hour,
dts.min, dts.sec, dts.us, tz)
delta = int(_get_utcoffset(tz, dt).total_seconds()) * 1000000000
delta = int(get_utcoffset(tz, dt).total_seconds()) * 1000000000
pandas_datetime_to_datetimestruct(stamps[i] + delta,
PANDAS_FR_ns, &dts)
curr_reso = _reso_stamp(&dts)
Expand Down Expand Up @@ -597,7 +597,7 @@ cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,
ndarray[int64_t] trans, deltas, pos
pandas_datetimestruct dts

if _is_utc(tz):
if is_utc(tz):
for i in range(n):
if stamps[i] == NPY_NAT:
result[i] = NPY_NAT
Expand All @@ -607,7 +607,7 @@ cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,
dts.hour, dts.min, dts.sec,
dts.us, dts.ps, freq)

elif _is_tzlocal(tz):
elif is_tzlocal(tz):
for i in range(n):
if stamps[i] == NPY_NAT:
result[i] = NPY_NAT
Expand All @@ -616,7 +616,7 @@ cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,
&dts)
dt = datetime(dts.year, dts.month, dts.day, dts.hour,
dts.min, dts.sec, dts.us, tz)
delta = int(_get_utcoffset(tz, dt).total_seconds()) * 1000000000
delta = int(get_utcoffset(tz, dt).total_seconds()) * 1000000000
pandas_datetime_to_datetimestruct(stamps[i] + delta,
PANDAS_FR_ns, &dts)
result[i] = get_period_ordinal(dts.year, dts.month, dts.day,
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from decimal import Decimal
cimport util
cimport cython
from tslib import NaT
from tslibs.timezones cimport _get_zone
from tslibs.timezones cimport get_timezone
from datetime import datetime, timedelta
iNaT = util.get_nat()

Expand Down Expand Up @@ -901,13 +901,13 @@ cpdef bint is_datetime_with_singletz_array(ndarray[object] values):
for i in range(n):
base_val = values[i]
if base_val is not NaT:
base_tz = _get_zone(getattr(base_val, 'tzinfo', None))
base_tz = get_timezone(getattr(base_val, 'tzinfo', None))

for j in range(i, n):
val = values[j]
if val is not NaT:
tz = getattr(val, 'tzinfo', None)
if base_tz != tz and base_tz != _get_zone(tz):
if base_tz != tz and base_tz != get_timezone(tz):
return False
break

Expand Down
Loading