European date format input

I have googled a lot on this subject but have not found an easy way to
have RoR accept european date format (DD/MM/YYYY) in forms. I looked
at globalize plugin but that feels heavy implementation for me because
I do not need translations.

bitterbal wrote:

I have googled a lot on this subject but have not found an easy way to
have RoR accept european date format (DD/MM/YYYY) in forms. I looked
at globalize plugin but that feels heavy implementation for me because
I do not need translations.

You can replace ParseDate.parsedate function which Rails use to parse
dates. Find article with implementation on my blog:
http://source.mihelac.org/articles/2006/09/13/parsing-european-date-format-in-ruby-rails

best regards,
Bojan

Bojan M.
-> Ruby on Rails and Web D. Blog : http://source.mihelac.org

Hello,

On 6 Mar 2007, at 12:23, bitterbal wrote:

I have googled a lot on this subject but have not found an easy way to
have RoR accept european date format (DD/MM/YYYY) in forms. I looked
at globalize plugin but that feels heavy implementation for me because
I do not need translations.

I’m not sure if this helps you, but you can define your own data
formats in environment.rb. For example:

ActiveSupport::CoreExtensions::date::Conversions::DATE_FORMATS.merge!(
:uk_full => ‘%e %B %Y’
)

And then use the symbolic form with Date.to_s. E.g. in a view:

<%= @order.created_at.to_s :uk_full %>

Regards,
Andy S.

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