def _date_str_to_datetime(date): matches = START_REGEX.match(date) raw_date_input = '{0}/{1}/{2}'.format(matches.group('day'), matches.group('month'), matches.group('year')) date_format = '%d/%b/%Y' if matches.group('hour'): date_format += ':%H' raw_date_input += ':{0}'.format(matches.group('hour')) if matches.group('minute'): date_format += ':%M' raw_date_input += ':{0}'.format(matches.group('minute')) if matches.group('second'): date_format += ':%S' raw_date_input += ':{0}'.format(matches.group('second')) return datetime.strptime(raw_date_input, date_format)
def _date_str_to_datetime(date): matches = START_REGEX.match(date) raw_date_input = '{0}/{1}/{2}'.format( matches.group('day'), matches.group('month'), matches.group('year') ) date_format = '%d/%b/%Y' if matches.group('hour'): date_format += ':%H' raw_date_input += ':{0}'.format(matches.group('hour')) if matches.group('minute'): date_format += ':%M' raw_date_input += ':{0}'.format(matches.group('minute')) if matches.group('second'): date_format += ':%S' raw_date_input += ':{0}'.format(matches.group('second')) return datetime.strptime(raw_date_input, date_format)
def _validate_arg_date(start): matches = START_REGEX.match(start) if not matches: raise ValueError('--start argument is not valid')