[Rails 3.1.3 / ruby 1.9.2 ]
I am trying to manage localized dates and I don’t actually understand
how it’s managed w Rails 3.1 … I thought there was no more issues w
I18n…
my locale is defined : I18n.locale => :fr
I am using a localized version of jQuery DatePicker , so it displays
selected dates in the text field like : 01/02/2012 (Feb first )
i.e. ( in generated html):
<inputid="start_shooting_date"class="text
hasDatepicker"type="text"value="01/02/2012"name=“project[start_shooting_date]”>
in my Project model , date validations are OK, then I store the
updated project
@project.update_attributes(params[:project])
and I get stored in the DB : start_shooting_date: “2012-01-02
00:00:00” (Jan 2nd) rather than “2012-02-01 00:00:00” ( Feb
first )
I’ll appreciated your feedback …
I defined in environment.rb ( don’t know if necessary… for input .
but it seems to be for output, or is it redundant with defaults .yml
files ?)
if locale french
Date::DATE_FORMATS.merge!( :default => “%d/%m/%Y” )
I also defined the I18n default format in the .yml files
fr:
date:
formats:
default: “%d/%m/%Y”
short: “%e %b”
long: “%e %B %Y”
full: “%A %d %B %Y”
time:
formats:
default: “%d %B %Y %H:%M:%S”
short: “%d %b %H:%M”
long: “%A %d %B %Y %H:%M”
am: ‘am’
pm: ‘pm’
en:
date:
formats:
default: “%Y-%m-%d”
short: “%b %d”
long: “%B %d, %Y”
full: “%A %B %d, %Y”
time:
formats:
default: “%a, %d %b %Y %H:%M:%S %z”
short: “%d %b %H:%M”
long: “%B %d, %Y %H:%M”
am: “am”
pm: “pm”