Date.strptime and DateTime.strptime do not properly parse certain forms of input in which there are no non-numeric separators
between the fields.
For example, the following code fails:
Date.strptime("20060401", "%Y%m%d")
ArgumentError: 3 elements of civil date are necessary
from /usr/local/lib/ruby/1.8/date.rb:650:in `new_with_hash'
from /usr/local/lib/ruby/1.8/date.rb:675:in `strptime'
from (irb):21
from /usr/local/lib/ruby/1.8/date.rb:1197
The following code, however, works as expected:
x = Date.strptime("2006 04 01", "%Y %m %d")
=> #<Date: 4907653/2,0,2299161> |