Robb Shecter wrote:
> I put something like this in one of my helpers:
> 
>   def format_date(a_date)
>      a_date.strftime("%B #{a_date.day}, %Y")
>   end
> 
> Should give you a starting point.

Personally, I like the pattern of having separate formatter classes, but 
using view helpers isn't too bad. For example the Cocoa framework 
provides NSDateFormatter and NSNumberFormatter. Java also has the 
SimpleDateFormat class for this purpose. And, responsibility for I18n 
can be delegated to the formatter classes as well.

I like this pattern because the view layer should be responsible for 
formatting values for display. Since Date and Time are model objects 
they really should not be responsible for formatting their own data.

But, I realize that opinions vary.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to