"""
Parses a date string. See DateParser docs for details.
"""
- import dateparse.dateparse_utils as dp
+ import dateparse.dateparse_utils as du
try:
- d = dp.DateParser()
+ d = du.DateParser() # type: ignore
d.parse(in_str)
return d.get_date()
- except dp.ParseException:
+ except du.ParseException: # type: ignore
msg = f'Unable to parse date {in_str}.'
logger.warning(msg)
return None
"""
True if the string represents a valid date.
"""
+ import dateparse
import dateparse.dateparse_utils as dp
try:
- d = dp.DateParser()
+ d = dp.DateParser() # type: ignore
_ = d.parse(in_str)
return True
- except dp.ParseException:
+ except dp.ParseException: # type: ignore
msg = f'Unable to parse date {in_str}.'
logger.warning(msg)
return False
import dateparse.dateparse_utils as dp
try:
- d = dp.DateParser()
+ d = dp.DateParser() # type: ignore
dt = d.parse(in_str)
if type(dt) == datetime.datetime:
return dt