File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,7 @@ cdef _array_to_datetime_object(
798
798
# We return an object array and only attempt to parse:
799
799
# 1) NaT or NaT-like values
800
800
# 2) datetime strings, which we return as datetime.datetime
801
+ # 3) special strings - "now" & "today"
801
802
for i in range (n):
802
803
val = values[i]
803
804
if checknull_with_nat_and_na(val) or PyDateTime_Check(val):
@@ -812,10 +813,16 @@ cdef _array_to_datetime_object(
812
813
oresult[i] = ' NaT'
813
814
continue
814
815
try :
815
- oresult[i] = parse_datetime_string(val, dayfirst = dayfirst,
816
+ # Handling special case strings today & now
817
+ if val == " today" :
818
+ oresult[i] = datetime.today()
819
+ elif val == " now" :
820
+ oresult[i] = datetime.now()
821
+ else :
822
+ oresult[i] = parse_datetime_string(val, dayfirst = dayfirst,
816
823
yearfirst = yearfirst)
817
- pydatetime_to_dt64(oresult[i], & dts)
818
- check_dts_bounds(& dts)
824
+ pydatetime_to_dt64(oresult[i], & dts)
825
+ check_dts_bounds(& dts)
819
826
except (ValueError , OverflowError ):
820
827
if is_coerce:
821
828
oresult[i] = < object > NaT
You can’t perform that action at this time.
0 commit comments