in mozregression/dates.py [0:0]
def parse_date(date_string):
"""
Returns a date or a datetime from a string.
"""
if len(date_string) == 14 and date_string.isdigit():
# probably a build id - transform that in a datetime
try:
return datetime.datetime.strptime(date_string, "%Y%m%d%H%M%S")
except ValueError:
raise DateFormatError(date_string, "Not a valid build id: `%s`")
regex = re.compile(r"(\d{4})\-(\d{1,2})\-(\d{1,2})")
matched = regex.match(date_string)
if not matched:
raise DateFormatError(date_string)
try:
return datetime.date(int(matched.group(1)), int(matched.group(2)), int(matched.group(3)))
except ValueError as ex:
raise DateValueError(date_string, ex)