Project

General

Profile

Actions

Bug #6193

closed

Time.new does not accept seconds as a String

Added by john_firebaugh (John Firebaugh) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
Backport:
[ruby-core:43569]

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:in initialize' from (irb):222:in new'
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

ruby-time-sec-str.patch (1.38 KB) ruby-time-sec-str.patch ssuda (Sambasiva Suda), 03/23/2012 11:53 PM
ruby-time-sec-str2.patch (1.57 KB) ruby-time-sec-str2.patch ssuda (Sambasiva Suda), 03/24/2012 06:48 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0