Skip to content

CLN: remove normalize_date, but really this time #34041

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
May 7, 2020
Merged
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
31 changes: 0 additions & 31 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -682,37 +682,6 @@ cpdef inline datetime localize_pydatetime(datetime dt, object tz):
# Normalization


def normalize_date(dt: object) -> datetime:
"""
Normalize datetime.datetime value to midnight. Returns datetime.date as a
datetime.datetime at midnight

Parameters
----------
dt : date, datetime, or Timestamp

Returns
-------
normalized : datetime.datetime or Timestamp

Raises
------
TypeError : if input is not datetime.date, datetime.datetime, or Timestamp
"""
if PyDateTime_Check(dt):
if isinstance(dt, _Timestamp):
return dt.replace(hour=0, minute=0, second=0, microsecond=0,
nanosecond=0)
else:
# regular datetime object
return dt.replace(hour=0, minute=0, second=0, microsecond=0)
# TODO: Make sure DST crossing is handled correctly here
elif PyDate_Check(dt):
return datetime(dt.year, dt.month, dt.day)
else:
raise TypeError(f'Unrecognized type: {type(dt)}')


@cython.wraparound(False)
@cython.boundscheck(False)
def normalize_i8_timestamps(int64_t[:] stamps, object tz):
Expand Down