Why a nil date makes I18n.l fail?

I’s all in the title!

I find it very painful, to always have to supply a date so that I18n.l
doesn’t miserably fail. Why doesn’t simply return “”???

Because that’s how it’s coded.

from: I18n::Backend.localize…

def localize(locale, object, format = :default)
raise ArgumentError, “Object must be a Date, DateTime or Time
object. #{object.inspect} given.” unless object.respond_to?(:strftime)

On Oct 12, 4:20 pm, Fernando P. [email protected]

2009/10/12 Fernando P. [email protected]:

I’s all in the title!

I find it very painful, to always have to supply a date so that I18n.l
doesn’t miserably fail. Why doesn’t simply return “”???

If you find yourself repeatedly doing something then your code is not
DRY. The solution might be to provide your own wrapper and call that.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs