ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:78374] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition
       [not found] <redmine.issue-12981.20161126133339@ruby-lang.org>
@ 2016-11-26 13:33 ` knt01222
  2016-11-26 13:35 ` [ruby-core:78375] " knt01222
  2016-12-25  8:21 ` [ruby-core:78826] " mailme
  2 siblings, 0 replies; 3+ messages in thread
From: knt01222 @ 2016-11-26 13:33 UTC (permalink / raw
  To: ruby-core

Issue #12981 has been reported by Kenta SHIRAI.

----------------------------------------
Bug #12981: Date.parse raises an Argument error under a specific condition
https://bugs.ruby-lang.org/issues/12981

* Author: Kenta SHIRAI
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Date.parse cannot accept incomplete strings whose delimiter is a hyphen like: "2016-11", although it can accept if a delimiter is a slash like: "2016/12"

I'm not really sure if this is a bug or an expected behavior, but a maintainer of rails/rails recommended me to report this to Ruby team when I issued a PR( https://github.com/rails/rails/pull/27181 ) to them.  So I'd appreciate if this issue is looked into.

steps to reproduce:

~~~ ruby
require "date"
=> true

Date.parse("2016/12/01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12-01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016/12")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12")
ArgumentError: invalid date
	from (irb):3:in `parse'
	from (irb):3
	from /usr/local/bin/irb:11:in `<main>'
~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:78375] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition
       [not found] <redmine.issue-12981.20161126133339@ruby-lang.org>
  2016-11-26 13:33 ` [ruby-core:78374] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition knt01222
@ 2016-11-26 13:35 ` knt01222
  2016-12-25  8:21 ` [ruby-core:78826] " mailme
  2 siblings, 0 replies; 3+ messages in thread
From: knt01222 @ 2016-11-26 13:35 UTC (permalink / raw
  To: ruby-core

Issue #12981 has been updated by Kenta SHIRAI.

Description updated

----------------------------------------
Bug #12981: Date.parse raises an Argument error under a specific condition
https://bugs.ruby-lang.org/issues/12981#change-61751

* Author: Kenta SHIRAI
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Date.parse cannot accept incomplete strings whose delimiter is a hyphen like: "2016-12", although it can accept if a delimiter is a slash like: "2016/12"

I'm not really sure if this is a bug or an expected behavior, but a maintainer of rails/rails recommended me to report this to Ruby team when I issued a PR( https://github.com/rails/rails/pull/27181 ) to them.  So I'd appreciate if this issue is looked into.

steps to reproduce:

~~~ ruby
require "date"
=> true

Date.parse("2016/12/01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12-01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016/12")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12")
ArgumentError: invalid date
	from (irb):3:in `parse'
	from (irb):3
	from /usr/local/bin/irb:11:in `<main>'
~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:78826] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition
       [not found] <redmine.issue-12981.20161126133339@ruby-lang.org>
  2016-11-26 13:33 ` [ruby-core:78374] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition knt01222
  2016-11-26 13:35 ` [ruby-core:78375] " knt01222
@ 2016-12-25  8:21 ` mailme
  2 siblings, 0 replies; 3+ messages in thread
From: mailme @ 2016-12-25  8:21 UTC (permalink / raw
  To: ruby-core

Issue #12981 has been updated by Alfred Dominic.


I see a similar inconsistency in the `Date._parse` method. Everything works fine as expected as long as the `/` delimiter is used.
I think it has something to do with `_parse` being able to parse strings with delimiter and one without it.

~~~ ruby
Date._parse("2016/12/01")
=> {:year=>2016, :mon=>12, :mday=>1}
Date._parse("2016-12-01")
=> {:year=>2016, :mon=>12, :mday=>1}
Date._parse("2016/12")
=> {:year=>2016, :mon=>12}
Date._parse("2016-12")
=> {:mon=>20, :mday=>16, :zone=>"-12", :offset=>-43200}
~~~

----------------------------------------
Bug #12981: Date.parse raises an Argument error under a specific condition
https://bugs.ruby-lang.org/issues/12981#change-62235

* Author: Kenta SHIRAI
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Date.parse cannot accept incomplete strings whose delimiter is a hyphen like: "2016-12", although it can accept if a delimiter is a slash like: "2016/12"

I'm not really sure if this is a bug or an expected behavior, but a maintainer of rails/rails recommended me to report this to Ruby team when I issued a PR( https://github.com/rails/rails/pull/27181 ) to them.  So I'd appreciate if this issue is looked into.

steps to reproduce:

~~~ ruby
require "date"
=> true

Date.parse("2016/12/01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12-01")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016/12")
=> #<Date: 2016-12-01 ((2457724j,0s,0n),+0s,2299161j)>

Date.parse("2016-12")
ArgumentError: invalid date
	from (irb):3:in `parse'
	from (irb):3
	from /usr/local/bin/irb:11:in `<main>'
~~~




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-25  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-12981.20161126133339@ruby-lang.org>
2016-11-26 13:33 ` [ruby-core:78374] [Ruby trunk Bug#12981] Date.parse raises an Argument error under a specific condition knt01222
2016-11-26 13:35 ` [ruby-core:78375] " knt01222
2016-12-25  8:21 ` [ruby-core:78826] " mailme

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).