Created
September 5, 2008 22:09
-
-
Save crash2burn/9037 to your computer and use it in GitHub Desktop.
This file contains 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
class DateTime | |
@@date_formats = { | |
:db => "%Y-%m-%d %H:%M:%S", | |
:time => "%H:%M", | |
:short => "%d %b %H:%M", | |
:long => "%B %d, %Y %H:%M", | |
:long_ordinal => lambda { |time| time.strftime("%B | |
#{time.day.ordinalize}, %Y %H:%M") }, | |
:rfc822 => "%a, %d %b %Y %H:%M:%S %z" | |
} | |
alias :old_to_s :to_s | |
def to_s(format = nil) | |
return old_to_s unless format | |
self.strftime(@@date_formats[format.to_sym]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment