@@ -107,7 +107,13 @@ cdef int64_t NPY_NAT = util.get_nat()
107
107
iNaT = NPY_NAT
108
108
109
109
110
- from tslibs.timezones cimport _is_utc
110
+ from tslibs.timezones cimport (
111
+ _is_utc, _is_tzlocal,
112
+ _treat_tz_as_dateutil, _treat_tz_as_pytz,
113
+ _get_zone,
114
+ _get_utcoffset)
115
+ from tslibs.timezones import get_timezone, _get_utcoffset # noqa
116
+
111
117
112
118
cdef inline object create_timestamp_from_ts(
113
119
int64_t value, pandas_datetimestruct dts,
@@ -235,10 +241,6 @@ def ints_to_pytimedelta(ndarray[int64_t] arr, box=False):
235
241
return result
236
242
237
243
238
- cdef inline bint _is_tzlocal(object tz):
239
- return isinstance (tz, _dateutil_tzlocal)
240
-
241
-
242
244
cdef inline bint _is_fixed_offset(object tz):
243
245
if _treat_tz_as_dateutil(tz):
244
246
if len (tz._trans_idx) == 0 and len (tz._trans_list) == 0 :
@@ -1443,11 +1445,6 @@ cdef class _TSObject:
1443
1445
def __get__ (self ):
1444
1446
return self .value
1445
1447
1446
- cpdef _get_utcoffset(tzinfo, obj):
1447
- try :
1448
- return tzinfo._utcoffset
1449
- except AttributeError :
1450
- return tzinfo.utcoffset(obj)
1451
1448
1452
1449
# helper to extract datetime and int64 from several different possibilities
1453
1450
cdef convert_to_tsobject(object ts, object tz, object unit,
@@ -1712,48 +1709,6 @@ def _localize_pydatetime(object dt, object tz):
1712
1709
return dt.replace(tzinfo = tz)
1713
1710
1714
1711
1715
- def get_timezone (tz ):
1716
- return _get_zone(tz)
1717
-
1718
-
1719
- cdef inline object _get_zone(object tz):
1720
- """
1721
- We need to do several things here:
1722
- 1) Distinguish between pytz and dateutil timezones
1723
- 2) Not be over-specific (e.g. US/Eastern with/without DST is same *zone*
1724
- but a different tz object)
1725
- 3) Provide something to serialize when we're storing a datetime object
1726
- in pytables.
1727
-
1728
- We return a string prefaced with dateutil if it's a dateutil tz, else just
1729
- the tz name. It needs to be a string so that we can serialize it with
1730
- UJSON/pytables. maybe_get_tz (below) is the inverse of this process.
1731
- """
1732
- if _is_utc(tz):
1733
- return ' UTC'
1734
- else :
1735
- if _treat_tz_as_dateutil(tz):
1736
- if ' .tar.gz' in tz._filename:
1737
- raise ValueError (
1738
- ' Bad tz filename. Dateutil on python 3 on windows has a '
1739
- ' bug which causes tzfile._filename to be the same for all '
1740
- ' timezone files. Please construct dateutil timezones '
1741
- ' implicitly by passing a string like "dateutil/Europe'
1742
- ' /London" when you construct your pandas objects instead '
1743
- ' of passing a timezone object. See '
1744
- ' https://github.com/pandas-dev/pandas/pull/7362' )
1745
- return ' dateutil/' + tz._filename
1746
- else :
1747
- # tz is a pytz timezone or unknown.
1748
- try :
1749
- zone = tz.zone
1750
- if zone is None :
1751
- return tz
1752
- return zone
1753
- except AttributeError :
1754
- return tz
1755
-
1756
-
1757
1712
cpdef inline object maybe_get_tz(object tz):
1758
1713
"""
1759
1714
(Maybe) Construct a timezone object from a string. If tz is a string, use
@@ -4285,13 +4240,6 @@ def tz_convert_single(int64_t val, object tz1, object tz2):
4285
4240
# Timezone data caches, key is the pytz string or dateutil file name.
4286
4241
dst_cache = {}
4287
4242
4288
- cdef inline bint _treat_tz_as_pytz(object tz):
4289
- return hasattr (tz, ' _utc_transition_times' ) and hasattr (
4290
- tz, ' _transition_info' )
4291
-
4292
- cdef inline bint _treat_tz_as_dateutil(object tz):
4293
- return hasattr (tz, ' _trans_list' ) and hasattr (tz, ' _trans_idx' )
4294
-
4295
4243
4296
4244
def _p_tz_cache_key (tz ):
4297
4245
""" Python interface for cache function to facilitate testing."""
0 commit comments