Bugs: Browse | Submit New | Admin

[#5263] strptime fails to properly parse certain inputs

Date:
2006-08-02 06:14
Priority:
3
Submitted By:
Michael Fischer (otterley)
Assigned To:
Yukihiro Matsumoto (matz)
Category:
Misc / Other Standard Library
State:
Closed
Platform:
 
Summary:
strptime fails to properly parse certain inputs

Detailed description
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>

Add A Comment: Notepad

Please login


Followup

Message
Date: 2006-08-03 14:23
Sender: Tom Copeland

This has been answered by Matz here:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/8485

Yours,

Tom

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
status_idOpen2006-08-03 14:23tom
assigned_tonone2006-08-03 14:23tom
close_date2006-08-03 14:232006-08-03 14:23tom