@@ -28,7 +28,7 @@ from pandas._libs.tslibs.timezones cimport (
28
28
# TODO: cdef scalar version to call from convert_str_to_tsobject
29
29
@ cython.boundscheck (False )
30
30
@ cython.wraparound (False )
31
- def tz_localize_to_utc (ndarray[int64_t] vals , object tz , object ambiguous = None ,
31
+ def tz_localize_to_utc (ndarray[int64_t] vals , tzinfo tz , object ambiguous = None ,
32
32
object nonexistent = None ):
33
33
"""
34
34
Localize tzinfo-naive i8 to given time zone (using pytz). If
@@ -329,7 +329,7 @@ cdef int64_t tz_convert_utc_to_tzlocal(int64_t utc_val, tzinfo tz, bint* fold=NU
329
329
return _tz_convert_tzlocal_utc(utc_val, tz, to_utc = False , fold = fold)
330
330
331
331
332
- cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
332
+ cpdef int64_t tz_convert_single(int64_t val, tzinfo tz1, tzinfo tz2):
333
333
"""
334
334
Convert the val (in i8) from timezone1 to timezone2
335
335
@@ -338,18 +338,15 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
338
338
Parameters
339
339
----------
340
340
val : int64
341
- tz1 : string / timezone object
342
- tz2 : string / timezone object
341
+ tz1 : tzinfo
342
+ tz2 : tzinfo
343
343
344
344
Returns
345
345
-------
346
346
converted: int64
347
347
"""
348
348
cdef:
349
- int64_t[:] deltas
350
- Py_ssize_t pos
351
- int64_t v, offset, utc_date
352
- npy_datetimestruct dts
349
+ int64_t utc_date
353
350
int64_t arr[1 ]
354
351
355
352
# See GH#17734 We should always be converting either from UTC or to UTC
@@ -381,17 +378,15 @@ cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
381
378
return _tz_convert_dst(arr, tz2, to_utc = False )[0 ]
382
379
383
380
384
- @ cython.boundscheck (False )
385
- @ cython.wraparound (False )
386
- def tz_convert (int64_t[:] vals , object tz1 , object tz2 ):
381
+ def tz_convert (int64_t[:] vals , tzinfo tz1 , tzinfo tz2 ):
387
382
"""
388
383
Convert the values (in i8) from timezone1 to timezone2
389
384
390
385
Parameters
391
386
----------
392
387
vals : int64 ndarray
393
- tz1 : string / timezone object
394
- tz2 : string / timezone object
388
+ tz1 : tzinfo
389
+ tz2 : tzinfo
395
390
396
391
Returns
397
392
-------
@@ -411,15 +406,15 @@ def tz_convert(int64_t[:] vals, object tz1, object tz2):
411
406
412
407
@ cython.boundscheck (False )
413
408
@ cython.wraparound (False )
414
- cdef int64_t[:] _tz_convert_one_way(int64_t[:] vals, object tz, bint to_utc):
409
+ cdef int64_t[:] _tz_convert_one_way(int64_t[:] vals, tzinfo tz, bint to_utc):
415
410
"""
416
411
Convert the given values (in i8) either to UTC or from UTC.
417
412
418
413
Parameters
419
414
----------
420
415
vals : int64 ndarray
421
- tz1 : string / timezone object
422
- to_utc : bint
416
+ tz1 : tzinfo
417
+ to_utc : bool
423
418
424
419
Returns
425
420
-------
@@ -430,7 +425,7 @@ cdef int64_t[:] _tz_convert_one_way(int64_t[:] vals, object tz, bint to_utc):
430
425
Py_ssize_t i, n = len (vals)
431
426
int64_t val
432
427
433
- if not is_utc(get_timezone(tz) ):
428
+ if not is_utc(tz ):
434
429
converted = np.empty(n, dtype = np.int64)
435
430
if is_tzlocal(tz):
436
431
for i in range (n):
0 commit comments