Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def when_date_string_is_parsed(self, date_string, fmt):
try:
self.result = strptime(date_string, fmt)
except ValueError as e:
self.result = e
def _get_date_obj(self, token, directive):
return strptime(token, directive)
def __call__(self, timestring):
_timestring = timestring
for directive in self.time_directives:
try:
return strptime(timestring.strip(), directive).time()
except ValueError:
pass
else:
raise ValueError('%s does not seem to be a valid time string' % _timestring)