Created
December 16, 2016 20:13
-
-
Save b-ggs/9ac43df5d4ad766bb5692bcc1992f758 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module DateHelper | |
| # Reference: http://www.foragoodstrftime.com/ | |
| def date_from_string(date_string) | |
| begin | |
| Date.strptime(date_string, "%m-%d-%Y") | |
| rescue ArgumentError => e | |
| nil | |
| end | |
| end | |
| def date_to_string(date) | |
| begin | |
| date.strftime("%m-%d-%Y") | |
| rescue ArgumentError => e | |
| nil | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment