Bug #6193
closedTime.new does not accept seconds as a String
Description
Time.new accepts any or all of the year, month, day, hour, or minute specified as a String, but does not accept a String value for seconds:
Time.new("2012", "3", "22", "8", "19", 30)
=> 2012-03-22 08:19:30 -0700
Time.new("2012", "3", "22", "8", "19", "30")
TypeError: can't convert String into an exact number
from (irb):222:ininitialize' from (irb):222:innew'
from (irb):222
from /Users/john/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `'
Since all other arguments can be strings, and since Time.utc and Time.local accept String seconds, I believe the expected behavior is that Time.new does as well.
Files
        
           Updated by ssuda (Sambasiva Suda) over 13 years ago
          Updated by ssuda (Sambasiva Suda) over 13 years ago
          
          
        
        
      
      - File ruby-time-sec-str.patch ruby-time-sec-str.patch added
Here is the patch which will fix the problem with the seconds. There is also pull request for github.
        
           Updated by john_firebaugh (John Firebaugh) over 13 years ago
          Updated by john_firebaugh (John Firebaugh) over 13 years ago
          
          
        
        
      
      I think you want to use the obj2subsecx helper, not obj2vint, so that fractional seconds are still supported.
        
           Updated by ssuda (Sambasiva Suda) over 13 years ago
          Updated by ssuda (Sambasiva Suda) over 13 years ago
          
          
        
        
      
      - File ruby-time-sec-str2.patch ruby-time-sec-str2.patch added
Here is the updated patch using obj2subsecx.
        
           Updated by nobu (Nobuyoshi Nakada) over 13 years ago
          Updated by nobu (Nobuyoshi Nakada) over 13 years ago
          
          
        
        
      
      - Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35122.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- time.c (time_init_1): Time.new will accept seconds as string or
 int. [ruby-core:43569][Bug #6193]