Skip to content

Instantly share code, notes, and snippets.

@b-ggs
Created December 16, 2016 20:13
Show Gist options
  • Save b-ggs/9ac43df5d4ad766bb5692bcc1992f758 to your computer and use it in GitHub Desktop.
Save b-ggs/9ac43df5d4ad766bb5692bcc1992f758 to your computer and use it in GitHub Desktop.
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