Issue #12833 has been updated by Jon Wolski.


I have a pull request at https://github.com/ruby/ruby/pull/1463. I can make a patch if that is preferable (though this is a very small change). 

Since this ticket is marked duplicate, should my patch go on the ticket that this one duplicates (even though that one is already resolved)?

----------------------------------------
Bug #12833: incorrect iso8601 parsing of YYYY-MM format
https://bugs.ruby-lang.org/issues/12833#change-60958

* Author: Jon Wolski
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
## Duplicate

This ticket duplicates https://bugs.ruby-lang.org/issues/12285

## Expected

`DateTime.iso8601('2016-10')` parses the input string as four-digit year and two-digit month.

```sh
$ ruby -r date -e "puts DateTime.iso8601('2016-10').iso8601"
2016-10-01T00:00:00+00:00
```

## Actual

`DateTime.iso8601('2016-10')` parses the input string as four-digit year and two-digit day-of-month. 

```sh
$ ruby -r date -e "puts DateTime.iso8601('2016-10').iso8601"
2016-01-10T00:00:00+00:00
```


## Steps to reproduce

```sh
$ ruby -v -r date -e "puts DateTime.iso8601('2016-10').iso8601"
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
2016-01-10T00:00:00+00:00
```

## More details


```sh
$ ruby -r date -e "puts Date._iso8601('2016-10')"
{:mday=>10, :year=>2016}
$ ruby -r date -e "puts Date._iso8601('2016-101')"
{:yday=>101, :year=>2016}
```

This seems to suggest that the "10" is parsed as day-of-month (`:mday`) in the case of "YYYY-DD", but "101" is parsed as day-of-year (`:yday`) in the case of "YYYY-DDD". (The 3-digit day part _does_ in fact represent the day-of-year; that feature is correct.)



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>