Created
September 10, 2012 18:27
-
-
Save bkerley/3692741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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