'Explicitly convert a string to a number and format as datetime or
time'

def _cast_time(self, value):

    match = TIME_REGEX.match(value)
    if match:
        if (match.group('microsecond') is not None):
            value = value[:12]
            pattern = '%M:%S.%f'
            fmt = numbers.FORMAT_DATE_TIME5
        elif (match.group('second') is None):
            fmt = numbers.FORMAT_DATE_TIME3
            pattern = '%H:%M'
        else:
            pattern = '%H:%M:%S'
            fmt = numbers.FORMAT_DATE_TIME6
        value = datetime.datetime.strptime(value, pattern)
        self.number_format = fmt
        return time_to_days(value)
