Redefining Date Constants without warnings

I thought this might be helpfull for someone.

Even though I'd love to se i18n available for Date class (as in rails...
through a lot of code), sometime you just want to use the month names in
your language without including a quite big model.
For god's sake, it's just an array!
So, every class has a #remove_const method, but it's private. Bummer.
But what if...mmmm


Date.send(:remove_const, "ABBR_MONTHNAMES")
Date.send(:remove_const, "ABBR_DAYNAMES")
Date.send(:remove_const, "DAYNAMES")

Date::ABBR_MONTHNAMES = [nil]+ %w(Ene Feb Mar Abr May Jun Jul Ago Sep
Oct Nov Dic)
Date::ABBR_DAYNAMES = %w(Dom Lun Mar Mie Jue Vie Sab)
Date::DAYNAMES = %w(Domingo Lunes Martes Miercoles Jueves Viernes

Neat!.. no warnings.

Posted via