Skip to content

Commit 071c165

Browse files
mroeschkedberenbaum
authored andcommitted
CLN: Use public method to capture UTC offsets (pandas-dev#22164)
1 parent c72e876 commit 071c165

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

pandas/_libs/tslib.pyx

+4-16
Original file line numberDiff line numberDiff line change
@@ -634,24 +634,12 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
634634

635635
# If the dateutil parser returned tzinfo, capture it
636636
# to check if all arguments have the same tzinfo
637-
tz = py_dt.tzinfo
637+
tz = py_dt.utcoffset()
638638
if tz is not None:
639639
seen_datetime_offset = 1
640-
if tz == dateutil_utc():
641-
# dateutil.tz.tzutc has no offset-like attribute
642-
# Just add the 0 offset explicitly
643-
out_tzoffset_vals.add(0)
644-
elif tz == tzlocal():
645-
# is comparison fails unlike other dateutil.tz
646-
# objects. Also, dateutil.tz.tzlocal has no
647-
# _offset attribute like tzoffset
648-
offset_seconds = tz._dst_offset.total_seconds()
649-
out_tzoffset_vals.add(offset_seconds)
650-
else:
651-
# dateutil.tz.tzoffset objects cannot be hashed
652-
# store the total_seconds() instead
653-
offset_seconds = tz._offset.total_seconds()
654-
out_tzoffset_vals.add(offset_seconds)
640+
# dateutil timezone objects cannot be hashed, so store
641+
# the UTC offsets in seconds instead
642+
out_tzoffset_vals.add(tz.total_seconds())
655643
else:
656644
# Add a marker for naive string, to track if we are
657645
# parsing mixed naive and aware strings

0 commit comments

Comments
 (0)