Skip to content

Commit d7d233a

Browse files
committed
CLN: clean up ugly dateutil imports
1 parent 8a85eec commit d7d233a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pandas/_libs/tslibs/conversion.pyx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ cimport numpy as cnp
55
from numpy cimport int64_t, int32_t, intp_t, ndarray
66
cnp.import_array()
77

8-
from dateutil.zoneinfo import tzfile as du_tzfile1
9-
from dateutil.tz.tz import tzfile as du_tzfile2
8+
from dateutil.tz import tzfile as _dateutil_tzfile
109

1110
import pytz
1211

@@ -386,13 +385,13 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
386385
else:
387386
obj.value = pydatetime_to_dt64(ts, &obj.dts)
388387
# GH 24329 Take DST offset into account
389-
# Two check in if necessary because class
390-
# differs on Windows and Linux
391-
if (isinstance(ts.tzinfo, du_tzfile1) or
392-
isinstance(ts.tzinfo, du_tzfile2)):
393-
if ts.tzinfo.is_ambiguous(ts):
394-
dst_offset = ts.tzinfo.dst(ts)
395-
obj.value += int(dst_offset.total_seconds() * 1e9)
388+
# use get_dst_info to get type
389+
if ts.tzinfo is not None:
390+
trans, deltas, typ = get_dst_info(ts.tzinfo)
391+
if isinstance(ts.tzinfo, _dateutil_tzfile):
392+
if ts.tzinfo.is_ambiguous(ts):
393+
dst_offset = ts.tzinfo.dst(ts)
394+
obj.value += int(dst_offset.total_seconds() * 1e9)
396395
obj.tzinfo = ts.tzinfo
397396

398397
if obj.tzinfo is not None and not is_utc(obj.tzinfo):

0 commit comments

Comments
 (0)