Skip to content

Instantly share code, notes, and snippets.

@ashaw
Last active December 31, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashaw/8056039 to your computer and use it in GitHub Desktop.
Save ashaw/8056039 to your computer and use it in GitHub Desktop.
def parse_date(d)
d.strip.gsub(/[^\d\/]/,"") =~ /(^[\d]{1,2}\/[\d]{1,2}\/[\d]{2}$)/
if $1
m, d, y = $1.split("/")
if y.to_i <= 13
y = "20#{y}"
else
y = "19#{y}"
end
Date.strptime("#{m}/#{d}/#{y}", "%m/%d/%Y")
else
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment