Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if len(datestrsplit) == 3:
if len(datestrsplit[0]) == 4 and len(datestrsplit[1]) == 2 and len(datestrsplit[2]) == 2:
return DateResolution.Day
#Check case 2
if len(isodatestr) == 8 and isodatestr.find('-') == -1:
return DateResolution.Day
#An ISO string may be a ordinal date representation if:
# 1) When split on a hyphen, the sizes of the parts are 4, 3
# 2) There are no hyphens, and the length is 7
#Check case 1
if len(datestrsplit) == 2:
if len(datestrsplit[0]) == 4 and len(datestrsplit[1]) == 3:
return DateResolution.Ordinal
#Check case 2
if len(isodatestr) == 7 and isodatestr.find('-') == -1:
return DateResolution.Ordinal
#None of the date representations match
raise ValueError('String is not an ISO 8601 date, perhaps it represents a time or datetime.')