Skip to content

Commit

Permalink
addressing review comments pandas-dev#2
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyi96 committed Aug 12, 2022
1 parent e55423d commit 5ce48c2
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ from pandas._libs.tslibs.util cimport (
get_c_string_buf_and_size,
is_array,
)
from pandas._libs.tslibs.timestamps import Timestamp


cdef extern from "../src/headers/portable.h":
Expand Down Expand Up @@ -300,7 +299,10 @@ def parse_datetime_string(
return dt

# Handling special case strings today & now
dt = _parse_today_now(date_string)
if date_string == "now":
dt = datetime.now()
elif date_string == "today":
dt = datetime.today()
if dt is not None:
return dt

Expand Down Expand Up @@ -1216,25 +1218,3 @@ cpdef str get_rule_month(str source):
return "DEC"
else:
return source.split("-")[1]

cdef inline object _parse_today_now(str date_string):
"""
Parse special case date inputs - "today", "now"
and if present return corresponding datetime object
Parameters
----------
date_string : str
Returns:
--------
datetime or None
"""
cdef:
object res = None

if date_string == "now":
res = Timestamp.utcnow()
elif date_string == "today":
res = Timestamp.today()
return res

0 comments on commit 5ce48c2

Please sign in to comment.