Project

General

Profile

Bug #12285

Date.iso8601 does not properly handle partial date strings

Added by backus (John Backus) about 3 years ago. Updated over 1 year ago.

Status:
Assigned
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:74956]

Description

For reduced accuracy, any number of values may be dropped from any of the date and time representations, but in the order from the least to the most significant. For example, "2004-05" is a valid ISO 8601 date, which indicates May (the fifth month) 2004.

From https://en.wikipedia.org/wiki/ISO_8601#cite_ref-AccuracyVsPrecision_8-0

However if I parse this example value with Date.iso8601 I get "January 5th, 2004" when I expect "May 1st, 2004":

$ irb -r date
2.3.0 :001 > date = Date.iso8601('2004-05')
 => #<Date: 2004-01-05 ((2453010j,0s,0n),+0s,2299161j)>
2.3.0 :002 > date.month
 => 1

Files

iso8601_YYYY_MM.patch (1.39 KB) iso8601_YYYY_MM.patch jonwolski (Jon Wolski), 12/11/2017 09:59 PM

Related issues

Has duplicate Ruby trunk - Bug #12833: incorrect iso8601 parsing of YYYY-MM formatOpenActions

History

Updated by backus (John Backus) almost 3 years ago

Could anyone tell me who to talk to find out if this issue is a WONTFIX? I have only reported a few things on this bug tracker so far so I'm not sure who to ping on an issue if it seems to be overlooked.

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

Date is not maintained now. We can not answer your concern.

Updated by zverok (Victor Shepelev) almost 3 years ago

Date is not maintained now. We can not answer your concern.

What does this mean? Date is in a separated gem now, or just not all of the standard library has its maintainers?
This is also related to DateTime, as far as I can understand?

Updated by backus (John Backus) almost 3 years ago

Victor Shepelev wrote:

Date is not maintained now. We can not answer your concern.

What does this mean? Date is in a separated gem now, or just not all of the standard library has its maintainers?
This is also related to DateTime, as far as I can understand?

I'm interested in the answer for this too. What exactly does "Date is not maintained" mean? Is there something in the documentation that conveys this? What else is not maintained in the standard library?

Updated by duerst (Martin Dürst) almost 3 years ago

There is some information about library maintainers e.g. at
https://bugs.ruby-lang.org/projects/ruby/wiki/MaintainersStdlib or
https://bugs.ruby-lang.org/projects/ruby/wiki/Contributors,
but these may not be up to date.

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Assignee set to tadf (tadayoshi funaba)
  • Status changed from Open to Assigned

As I read the code, Date.iso8601 allows to omit a month by '-', but not a day.
It feels like a bug to me, but uncertain.

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

all of the standard library has its maintainers?

Yes. See https://github.com/ruby/ruby/blob/trunk/doc/maintainers.rdoc

#8

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Has duplicate Bug #12833: incorrect iso8601 parsing of YYYY-MM format added

Updated by jonwolski (Jon Wolski) over 1 year ago

I had submitted a patch to an issue that got marked as a 'duplicate' (though it is still "open"). My ticket is not "assigned," so maybe it would help to add the patch here as well. Also, the corresponding pull-request on GitHub is https://github.com/ruby/ruby/pull/1463

Also available in: Atom PDF