Skip to content

Instantly share code, notes, and snippets.

@bkerley
Created September 10, 2012 18:27
Show Gist options
  • Save bkerley/3692741 to your computer and use it in GitHub Desktop.
Save bkerley/3692741 to your computer and use it in GitHub Desktop.
def normalize_date(date, default)
case date
when String
Date.parse(date).iso8601 # raise exceptions if it's bad, desired behavior
when Date
date.iso8601
when Time
date.to_date.iso8601
when nil
default.iso8601
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment