Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created August 9, 2023 17:32
Show Gist options
  • Save dpaluy/0ee2f059005b5d38b53483e51f6df4ee to your computer and use it in GitHub Desktop.
Save dpaluy/0ee2f059005b5d38b53483e51f6df4ee to your computer and use it in GitHub Desktop.
Date parser
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