@@ -312,18 +312,21 @@ cdef inline str _render_tstamp(int64_t val):
312
312
# ----------------------------------------------------------------------
313
313
# Timezone Conversion
314
314
315
- cdef int64_t tz_convert_utc_to_tzlocal(int64_t utc_val, tzinfo tz):
315
+ cdef int64_t tz_convert_utc_to_tzlocal(int64_t utc_val, tzinfo tz, bint * fold = NULL ):
316
316
"""
317
317
Parameters
318
318
----------
319
319
utc_val : int64_t
320
320
tz : tzinfo
321
+ fold : bint*
322
+ pointer to fold: whether datetime ends up in a fold or not
323
+ after adjustment
321
324
322
325
Returns
323
326
-------
324
327
local_val : int64_t
325
328
"""
326
- return _tz_convert_tzlocal_utc(utc_val, tz, to_utc = False )
329
+ return _tz_convert_tzlocal_utc(utc_val, tz, to_utc = False , fold = fold )
327
330
328
331
329
332
cpdef int64_t tz_convert_single(int64_t val, object tz1, object tz2):
@@ -489,7 +492,8 @@ cdef inline int64_t _tzlocal_get_offset_components(int64_t val, tzinfo tz,
489
492
return int (get_utcoffset(tz, dt).total_seconds()) * 1000000000
490
493
491
494
492
- cdef int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz, bint to_utc = True ):
495
+ cdef int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz, bint to_utc = True ,
496
+ bint* fold = NULL ):
493
497
"""
494
498
Convert the i8 representation of a datetime from a tzlocal timezone to
495
499
UTC, or vice-versa.
@@ -502,32 +506,6 @@ cdef int64_t _tz_convert_tzlocal_utc(int64_t val, tzinfo tz, bint to_utc=True):
502
506
tz : tzinfo
503
507
to_utc : bint
504
508
True if converting tzlocal _to_ UTC, False if going the other direction
505
-
506
- Returns
507
- -------
508
- result : int64_t
509
- """
510
- cdef int64_t delta
511
-
512
- delta = _tzlocal_get_offset_components(val, tz, to_utc, NULL )
513
-
514
- if to_utc:
515
- return val - delta
516
- else :
517
- return val + delta
518
-
519
-
520
- cdef int64_t _tz_convert_tzlocal_fromutc(int64_t val, tzinfo tz, bint * fold):
521
- """
522
- Convert the i8 representation of a datetime from UTC to local timezone,
523
- set fold by pointer
524
-
525
- Private, not intended for use outside of tslibs.conversion
526
-
527
- Parameters
528
- ----------
529
- val : int64_t
530
- tz : tzinfo
531
509
fold : bint*
532
510
pointer to fold: whether datetime ends up in a fold or not
533
511
after adjustment
@@ -540,11 +518,15 @@ cdef int64_t _tz_convert_tzlocal_fromutc(int64_t val, tzinfo tz, bint *fold):
540
518
-----
541
519
Sets fold by pointer
542
520
"""
543
- cdef int64_t delta
521
+ cdef:
522
+ int64_t delta
544
523
545
- delta = _tzlocal_get_offset_components(val, tz, False , fold)
524
+ delta = _tzlocal_get_offset_components(val, tz, to_utc , fold)
546
525
547
- return val + delta
526
+ if to_utc:
527
+ return val - delta
528
+ else :
529
+ return val + delta
548
530
549
531
550
532
@ cython.boundscheck (False )
0 commit comments