Created
August 9, 2023 17:32
-
-
Save dpaluy/0ee2f059005b5d38b53483e51f6df4ee to your computer and use it in GitHub Desktop.
Date parser
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
format_str = "%m/%d/" + (date_str =~ /\d{4}/ ? "%Y" : "%y") | |
date = Date.parse(date_str) rescue Date.strptime(date_str, format_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment