Skip to content

Instantly share code, notes, and snippets.

@smartworld-dm
Created March 12, 2020 18:11
Show Gist options
  • Save smartworld-dm/04f5e0821274680604ea7883392839b4 to your computer and use it in GitHub Desktop.
Save smartworld-dm/04f5e0821274680604ea7883392839b4 to your computer and use it in GitHub Desktop.
def validate_iso8601_date(date_str):
regex = r'^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[01]|0[1-9]|[12][0-9])$'
match_iso8601_date = re.compile(regex).match
try:
if match_iso8601_date( date_str ) is not None:
return True
except:
pass
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment