Skip to content

Commit 81f8a33

Browse files
committed
Assert at least one tz arg is always UTC
closes pandas-dev#17734
1 parent 3493aba commit 81f8a33

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/_libs/tslibs/conversion.pyx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
422422
pandas_datetimestruct dts
423423
datetime dt
424424

425+
assert is_utc(tz1) or is_utc(tz2)
426+
# See GH#17734
427+
425428
if val == NPY_NAT:
426429
return val
427430

@@ -445,7 +448,7 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
445448
if get_timezone(tz2) == 'UTC':
446449
return utc_date
447450
if is_tzlocal(tz2):
448-
dt64_to_dtstruct(val, &dts)
451+
dt64_to_dtstruct(utc_date, &dts)
449452
dt = datetime(dts.year, dts.month, dts.day, dts.hour,
450453
dts.min, dts.sec, dts.us, tz2)
451454
delta = int(get_utcoffset(tz2, dt).total_seconds()) * 1000000000
@@ -487,6 +490,9 @@ def tz_convert(ndarray[int64_t] vals, object tz1, object tz2):
487490
pandas_datetimestruct dts
488491
datetime dt
489492

493+
assert is_utc(tz1) or is_utc(tz2)
494+
# See GH#17734
495+
490496
if len(vals) == 0:
491497
return np.array([], dtype=np.int64)
492498

0 commit comments

Comments
 (0)