Skip to content

Instantly share code, notes, and snippets.

@mjordan
Last active June 28, 2022 05:41
Show Gist options
  • Save mjordan/5bf8e71b3d963a44cd2e64db01ae7086 to your computer and use it in GitHub Desktop.
Save mjordan/5bf8e71b3d963a44cd2e64db01ae7086 to your computer and use it in GitHub Desktop.
import time
def validate_date(date):
"""
Validates a yyyy-mm-dd date string.
- **date**: the date string to validate.
"""
try:
is_valid = time.strptime(date, '%Y-%m-%d')
except ValueError:
return False
# If there's no ValueError, date validates.
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment