makoto kuwata wrote:
> Does anyone help me?
> The following is an example to be converted invalid
> date automatically (2008-02-31 -> 2008-03-02).
> I want to stop this convertion.
> 
> $ ruby script/generate scaffold person name:string birth:date
> $ rake db:migrate
> $ ruby script/console
>>> hash = {"name"=>"Foo", "birth(1i)"=>"2008", "birth(2i)"=>"2", 
>>> "birth(3i)"=>"31"}
>>> person = Person.new(hash)
>>> p person
> #<Person id: nil, name: "Foo", birth: "2008-03-02", created_at: nil,
> updated_at: nil>
> 
> --
> makoto kuwata

There is no February 31, 2008 (2008-02-31).  This year, 2008, is a leap 
year so there WAS a February 29, 2008. The next day would be March 1, 
2008 (February 30, 2008 by your calendar) and the day after March 2, 
2008 (2008-03-02) or February 31, 2008 on your calendar.  So Rails/Ruby 
"fixed" it for you.  If you don't want that behaviour, use strings for 
you special two extra days in February.  (What are you gong to do next 
year without February 29, 2009?    :)

CEO Summary:
ROR got your back!
-- 
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