Project

General

Profile

Actions

Bug #12285

closed

Date.iso8601 does not properly handle partial date strings

Added by backus (John Backus) about 6 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
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 2 (0 open2 closed)

Has duplicate Ruby master - Bug #12833: incorrect iso8601 parsing of YYYY-MM formatClosedActions
Has duplicate Ruby master - Bug #12981: Date.parse raises an Argument error under a specific conditionClosedActions
Actions

Also available in: Atom PDF