Skip to content

CLN: type tz kwarg in create_timestamp_from_ts #35067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from cpython.datetime cimport (
datetime,
time,
timedelta,
tzinfo,
)
# import datetime C API
PyDateTime_IMPORT
Expand Down Expand Up @@ -77,9 +78,9 @@ from pandas._libs.missing cimport checknull_with_nat_and_na
cdef inline object create_datetime_from_ts(
int64_t value,
npy_datetimestruct dts,
object tz,
tzinfo tz,
object freq,
bint fold
bint fold,
):
"""
Convenience routine to construct a datetime.datetime from its parts.
Expand All @@ -92,7 +93,7 @@ cdef inline object create_datetime_from_ts(
cdef inline object create_date_from_ts(
int64_t value,
npy_datetimestruct dts,
object tz,
tzinfo tz,
object freq,
bint fold
):
Expand All @@ -106,7 +107,7 @@ cdef inline object create_date_from_ts(
cdef inline object create_time_from_ts(
int64_t value,
npy_datetimestruct dts,
object tz,
tzinfo tz,
object freq,
bint fold
):
Expand All @@ -120,7 +121,7 @@ cdef inline object create_time_from_ts(
@cython.boundscheck(False)
def ints_to_pydatetime(
const int64_t[:] arr,
object tz=None,
tzinfo tz=None,
object freq=None,
bint fold=False,
str box="datetime"
Expand Down Expand Up @@ -162,7 +163,7 @@ def ints_to_pydatetime(
str typ
int64_t value, delta, local_value
ndarray[object] result = np.empty(n, dtype=object)
object (*func_create)(int64_t, npy_datetimestruct, object, object, bint)
object (*func_create)(int64_t, npy_datetimestruct, tzinfo, object, bint)

if box == "date":
assert (tz is None), "tz should be None when converting to date"
Expand All @@ -178,7 +179,9 @@ def ints_to_pydatetime(
elif box == "datetime":
func_create = create_datetime_from_ts
else:
raise ValueError("box must be one of 'datetime', 'date', 'time' or 'timestamp'")
raise ValueError(
"box must be one of 'datetime', 'date', 'time' or 'timestamp'"
)

if is_utc(tz) or tz is None:
for i in range(n):
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/timestamps.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cpython.datetime cimport datetime
from cpython.datetime cimport datetime, tzinfo

from numpy cimport int64_t

Expand All @@ -8,7 +8,7 @@ from pandas._libs.tslibs.np_datetime cimport npy_datetimestruct

cdef object create_timestamp_from_ts(int64_t value,
npy_datetimestruct dts,
object tz, object freq, bint fold)
tzinfo tz, object freq, bint fold)


cdef class _Timestamp(ABCTimestamp):
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ _no_input = object()

cdef inline object create_timestamp_from_ts(int64_t value,
npy_datetimestruct dts,
object tz, object freq, bint fold):
tzinfo tz, object freq, bint fold):
""" convenience routine to construct a Timestamp from its parts """
cdef _Timestamp ts_base
ts_base = _Timestamp.__new__(Timestamp, dts.year, dts.month,
Expand Down