Bug #634
Time parsing works in 1.8 but not 1.9
| Status: | Rejected | Start date: | 10/11/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | 12/24/2008 | |
| Assignee: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | 1.9.1 Release Candidate | |||
| ruby -v: |
Description
This works in 1.8, but results in "ArgumentError: argument out of range" in 1.9:
require 'time'
Time::parse('06/21/95 04:24:34 PM')
History
Updated by Roger Pack over 3 years ago
seems that Date is similarly broken on 1.9, working on 1.8
require 'date'
Date::parse('06/21/95')
~ ruby19 test.rb
/Users/rogerpack/dev/ruby_19_installed/lib/ruby/1.9.0/date.rb:1022:in `new_by_frags': invalid date (ArgumentError)
from /Users/rogerpack/dev/ruby_19_installed/lib/ruby/1.9.0/date.rb:1066:in `parse'
from test.rb:2:in `<main>'
Updated by Koichi Sasada about 3 years ago
- Assignee set to Yukihiro Matsumoto
Updated by Yuki Sonoda about 3 years ago
- Target version set to 1.9.1 Release Candidate
Updated by Yuki Sonoda about 3 years ago
- Due date set to 12/24/2008
- Assignee deleted (
Yukihiro Matsumoto)
Updated by tadayoshi funaba about 3 years ago
This is an intentional change (r12859).
Updated by Yuki Sonoda about 3 years ago
On 12/21/08 2:13 PM, tadayoshi funaba wrote: > This is an intentional change (r12859). Can I regard this issue as rejected? -- Yugui <yugui@yugui.jp> http://yugui.jp
Updated by tadayoshi funaba about 3 years ago
yes, at least this is not a bug, i think.
Updated by Yuki Sonoda about 3 years ago
- Status changed from Open to Rejected
Updated by Roger Pack about 3 years ago
>> This is an intentional change (r12859).
>
> Can I regard this issue as rejected?
Seems somewhat surprising to me that
Date::parse('06/21/95')
doesn't parse, though I suppose that's better than what 1.8.x currently does:
irb(main):004:0> Date.parse("08/21/97").to_s
=> "0097-08-21"
Which is definitely bad :)
Should I file these as feature requests to have them work [and guess century].
Also should I file a feature request to change Time.parse to raise on
failed parse instead of returning Time.now [as you can't currently
determine if a time parsed successfully or not--at least not easily].
Thanks!
-=R
Updated by Yukihiro Matsumoto about 3 years ago
In message "Re: [ruby-core:20779] Re: [Bug #634] Time parsing works in 1.8 but not 1.9" on Mon, 22 Dec 2008 16:36:53 +0900, "Roger Pack" <rogerpack2005@gmail.com> writes: | |>> This is an intentional change (r12859). |> |> Can I regard this issue as rejected? | |Seems somewhat surprising to me that |Date::parse('06/21/95') | |doesn't parse, though I suppose that's better than what 1.8.x currently does: |irb(main):004:0> Date.parse("08/21/97").to_s |=> "0097-08-21" | |Which is definitely bad :) "dd/dd/dd" format itself is very culture dependent and ambiguous. It is yy/mm/dd in Japan (and other countries), mm/dd/yy in USA, dd/mm/yy in European countries, right? In some cases, you can tell them by accident, but we should not rely on luck in general cases. I believe that is the reason parsing this format is disabled in 1.9. |Also should I file a feature request to change Time.parse to raise on |failed parse instead of returning Time.now [as you can't currently |determine if a time parsed successfully or not--at least not easily]. It seems reasonable. You can file a feature request for this issue. matz.
Updated by Roger Pack almost 3 years ago
should Date.parse("4/30/2009")
parse in 1.9?
>> Date.parse("4/30/2009")
ArgumentError: invalid date
...
Thanks!