They didn't worke for me either, so I rewrote the to_s method for
dates and times:
Date.class_eval do
def to_s( format_name = :default )
format = case format_name
when String
self.strftime( format )
when Symbol
I18n.localize( self, :format => format_name)
end
end
end
Time.class_eval do
def to_s( format_name = :default )
format = case format_name
when String
self.strftime( format )
when Symbol
I18n.localize( self, :format => format_name)
end
end
end
I did also search for reasons why it doesn't work (from the I18N docs
it seemed that it should work), but this method at the Date object
shows that it has no idea about I18N:
def to_formatted_s(format = :default)
if formatter = DATE_FORMATS[format]
if formatter.respond_to?(:call)
formatter.call(self).to_s
else
strftime(formatter)
end
else
to_default_s
end
end
-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) |
http://blog.codevader.com/ (en)