@@ -107,7 +107,24 @@ def parse_datetime_string(date_string, freq=None, dayfirst=False,
107
107
108
108
109
109
def parse_time_string (arg , freq = None , dayfirst = None , yearfirst = None ):
110
- """ See tslib.parse_time_string.__doc__"""
110
+ """
111
+ Try hard to parse datetime string, leveraging dateutil plus some extra
112
+ goodies like quarter recognition.
113
+
114
+ Parameters
115
+ ----------
116
+ arg : compat.string_types
117
+ freq : str or DateOffset, default None
118
+ Helps with interpreting time string if supplied
119
+ dayfirst : bool, default None
120
+ If None uses default from print_config
121
+ yearfirst : bool, default None
122
+ If None uses default from print_config
123
+
124
+ Returns
125
+ -------
126
+ datetime, datetime/dateutil.parser._result, str
127
+ """
111
128
if not isinstance (arg, string_types):
112
129
return arg
113
130
@@ -121,9 +138,14 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
121
138
from pandas.core.config import get_option
122
139
yearfirst = get_option(" display.date_yearfirst" )
123
140
124
- return parse_datetime_string_with_reso(arg, freq = freq,
125
- dayfirst = dayfirst,
126
- yearfirst = yearfirst)
141
+ res = parse_datetime_string_with_reso(arg, freq = freq,
142
+ dayfirst = dayfirst,
143
+ yearfirst = yearfirst)
144
+ if res[0 ] is NAT_SENTINEL:
145
+ from pandas._libs.tslib import NaT
146
+ res = (NaT,) + res[1 :]
147
+ return res
148
+
127
149
128
150
129
151
def parse_datetime_string_with_reso (date_string , freq = None , dayfirst = False ,
@@ -349,10 +371,7 @@ def dateutil_parse(object timestr, object default, ignoretz=False,
349
371
350
372
351
373
# The canonical place for this appears to be in frequencies.pyx.
352
- @ cython.returns (object )
353
- @ cython.locals (source = object , default = object )
354
- @cython.ccall
355
- def _get_rule_month (source , default = ' DEC' ):
374
+ cpdef object _get_rule_month(object source, object default = ' DEC' ):
356
375
"""
357
376
Return starting month of given freq, default is December.
358
377
0 commit comments