In ruby 1.8, for dates in format mm/dd/yyyy, I get this:
$ ruby -rparsedate -e 'p ParseDate.parsedate("09/01/2008")'
[2008, 9, 1, nil, nil, nil, nil, nil]
$ ruby -rtime -e 'p Time.parse("9/1/2008")'
Mon Sep 01 00:00:00 -0400 2008
but in 1.9, I get this:
$ ruby19 -rtime -e 'p Time.parse("9/1/2008")'
2008-01-09 00:00:00 -0500
Of course 9/1 is ambiguous, but even for a non-ambiguous date, 1.9
actually gives an error:
$ ruby -rtime -e 'p Time.parse("09/15/2008")'
Mon Sep 15 00:00:00 -0400 2008
$ ruby19 -rtime -e 'p Time.parse("09/15/2008")'
/usr/local/lib/ruby/1.9.0/time.rb:184:in `local': argument out of
range (ArgumentError)
from /usr/local/lib/ruby/1.9.0/time.rb:184:in `make_time'
from /usr/local/lib/ruby/1.9.0/time.rb:243:in `parse'
from -e:1:in `<main>'
Is there any way I can easily tell Time::parse to favor mm/dd/yyyy
over dd/mm/yyyy? I can't use strptime because I have no idea what
format the dates are in. Also, I don't want to have to write code to
figure out the format first, since that would mean I'm essentially
writing my own Time::parse.
Cheers,
Jim