Created
July 29, 2016 03:28
-
-
Save edwinlab/f7e7fc0a3e2ad295719d531a94e8f56e to your computer and use it in GitHub Desktop.
Checking string is valid date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_date date | |
begin | |
Date.parse(date) | |
rescue ArgumentError | |
Date.today | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment