Bug 719921

Summary: Date class init from string incorrect parsing
Product: Red Hat Enterprise Linux 5 Reporter: Giovanni Cangiani <giovanni>
Component: rubyAssignee: Vít Ondruch <vondruch>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: high Docs Contact:
Priority: unspecified    
Version: 5.8   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-12 08:14:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Giovanni Cangiani 2011-07-08 12:29:58 UTC
Description of problem:
in /usr/lib/ruby/1.8/date/format.rb the function self.__strptime(str, fmt, elem) (line 87)
when reading the month data skips the third entry (%d). looks like it's eaten by %m.

Version-Release number of selected component (if applicable):
ruby 1.8.5

How reproducible:
100%

Steps to Reproduce:
# ruby
require 'date'
d=Date.strptime("20110103", "%Y%m%d")
p d
  
Actual results:
/usr/lib/ruby/1.8/date.rb:650:in `new_with_hash': 3 elements of civil date are necessary (ArgumentError)
	from /usr/lib/ruby/1.8/date.rb:675:in `strptime'
	from -:2


Expected results:
#<Date: 2011-01-03 (4911129/2,0,2299161)>

Additional info:
this bug is no longer present in ruby 1.8.7 so it is just a matter of updating the rpm for ruby

Comment 1 Vít Ondruch 2011-07-28 06:36:27 UTC
Hello Giovanni,

Rebase of Ruby to 1.8.7 version is not possible for RHEL-5. So this is not solution. Do you have by a chance patch which is fixing this issue? Nevertheless I am afraid that RHEL-5 is at end of cycle, so only bugs with huge impact are approved to be fixed. I am not sure this bug is one of them.

Comment 2 Vít Ondruch 2011-10-12 08:14:20 UTC
At the end, it is not bug according to Matz:

http://rubyforge.org/tracker/?func=detail&atid=1698&aid=5263&group_id=426