Project

General

Profile

Actions

Bug #12833

closed

incorrect iso8601 parsing of YYYY-MM format

Added by jonwolski (Jon Wolski) about 8 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:77605]

Description

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.

$ 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.

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

Steps to reproduce

$ 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

$ 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.)


Files

iso8601_YYYY_MM.patch (1.39 KB) iso8601_YYYY_MM.patch jonwolski (Jon Wolski), 10/22/2016 04:01 PM

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #12285: Date.iso8601 does not properly handle partial date stringsClosedActions

Updated by jonwolski (Jon Wolski) about 8 years ago

  • Description updated (diff)

Updated by jonwolski (Jon Wolski) about 8 years ago

  • Description updated (diff)
  • Assignee set to tadf (tadayoshi funaba)

Updated by jonwolski (Jon Wolski) about 8 years ago

  • Description updated (diff)
  • Assignee deleted (tadf (tadayoshi funaba))

I searched for this issue, before filing this ticket. However, I just discovered https://bugs.ruby-lang.org/issues/12285 which reports this same issue.

Updated by jonwolski (Jon Wolski) about 8 years ago

  • Description updated (diff)
Actions #5

Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • Is duplicate of Bug #12285: Date.iso8601 does not properly handle partial date strings added

Updated by jonwolski (Jon Wolski) about 8 years ago

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)?

Actions #8

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset git|75fb0a9afad1685cedee9c7665a7f30ec95068fc.


Allow mday in Date.iso8601 to be omitted

[Bug #12285]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0