@@ -5,8 +5,7 @@ cimport numpy as cnp
5
5
from numpy cimport int64_t, int32_t, intp_t, ndarray
6
6
cnp.import_array()
7
7
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
10
9
11
10
import pytz
12
11
@@ -386,13 +385,13 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, object tz,
386
385
else :
387
386
obj.value = pydatetime_to_dt64(ts, & obj.dts)
388
387
# 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 )
396
395
obj.tzinfo = ts.tzinfo
397
396
398
397
if obj.tzinfo is not None and not is_utc(obj.tzinfo):
0 commit comments