From: MonkeeSage Date: 2007-12-28T03:45:00+09:00 Subject: Re: change string to date error On Dec 27, 12:21 pm, Junkone wrote: > On Dec 27, 9:06 am, fw wrote: > > > > > On Thu, 2007-12-27 at 22:39 +0900, Junkone wrote: > > > i get the following error. wonder why > > > > irb(main):068:0> @@config["date"] > > > => "27/12/2007" > > > irb(main):069:0> Time.parse(@@config["date"]) > > > ArgumentError: argument out of range > > > from e:/ruby/lib/ruby/1.8/time.rb:184:in `local' > > > from e:/ruby/lib/ruby/1.8/time.rb:184:in `make_time' > > > from e:/ruby/lib/ruby/1.8/time.rb:243:in `parse' > > > from (irb):69 > > > from :0 > > > irb(main):070:0> > > > You have the month and day swapped - there's no 27th month in a year: > > > $ irb > > irb(main):001:0> require 'time' > > => true > > irb(main):002:0> Time.parse('27/12/2007') > > ArgumentError: argument out of range > > from /home/felix/ruby1.8.6/lib/ruby/1.8/time.rb:184:in `local' > > from /home/felix/ruby1.8.6/lib/ruby/1.8/time.rb:184:in > > `make_time' > > from /home/felix/ruby1.8.6/lib/ruby/1.8/time.rb:243:in `parse' > > from (irb):2 > > irb(main):003:0> Time.parse('12/27/2007') > > => Thu Dec 27 00:00:00 -0800 2007 > > irb(main):004:0> > > > HTH, > > > Felix > > i have a canadian layout and my regional settings on my computer is > set to dd/mm/yyyy. strange that ruby cannot get this one right. all my > office apps and my oracle and mysql databases now recognise this > format on my computer. Here ya go, eh. ;) Time.parse(@@config["date"].gsub(/(.*?)\/(.*?)\/(.*)/, '\2/\1/\3')) Regards, Jordan