Skip to content

Instantly share code, notes, and snippets.

@dpickett
Created November 10, 2011 18:20
Show Gist options
  • Save dpickett/1355645 to your computer and use it in GitHub Desktop.
Save dpickett/1355645 to your computer and use it in GitHub Desktop.
def start_date=(date_string = "")
if date_string.blank?
@start_date = nil
else
if date_string.is_a?(String) && !date_string.blank?
begin
@start_date = Time.strptime(date_string, "%m/%d/%Y")
rescue ArgumentError => e
#the date failed to parse
@start_date = nil
end
else
@start_date = date_string
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment