Project

General

Profile

Bug #14790

DateTime.iso8601 parses incorrect ISO8601

Added by Quintasan (Michał Zając) 7 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.4.2p198
[ruby-core:87276]

Description

I noticed it today when migrating to Time in my library but DateTime somehow parses incorrect ISO8601 dates. Technically that's a feature but I believe this behaviour is incorrect. Time#iso8601 behaves correctly in this case.

Steps to reproduce

require 'time'
date = "2018-05-17T12:17:11+0200"
DateTime.iso8601(date) # => #<DateTime: 2018-05-17T12:17:11+02:00 ((2458256j,37031s,0n),+7200s,2299161j)>
Time.iso8601(date) # ArgumentError: invalid date: "2018-05-17T12:17:11+0200"

Associated revisions

Revision 71fed537
Added by nobu (Nobuyoshi Nakada) 7 months ago

time.rb: fix parsing time zone in iso8601

  • lib/time.rb (Time.xmlschema): a colon in time zone designator can be omitted. [Bug #14790]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63512
Added by nobu (Nobuyoshi Nakada) 7 months ago

time.rb: fix parsing time zone in iso8601

  • lib/time.rb (Time.xmlschema): a colon in time zone designator can be omitted. [Bug #14790]

Revision dc2a979b
Added by nobu (Nobuyoshi Nakada) 7 months ago

time.rb: fix parsing time zone in iso8601

  • lib/time.rb (Time.xmlschema): the minute in time zone designator can be omitted together with the preceding colon. [Bug #14790]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63514
Added by nobu (Nobuyoshi Nakada) 7 months ago

time.rb: fix parsing time zone in iso8601

  • lib/time.rb (Time.xmlschema): the minute in time zone designator can be omitted together with the preceding colon. [Bug #14790]

Revision 9f86a436
Added by usa (Usaku NAKAMURA) 4 months ago

merge revision(s) 63512,63514: [Backport #14790]

    time.rb: fix parsing time zone in iso8601

    * lib/time.rb (Time.xmlschema): a colon in time zone designator
      can be omitted.   [Bug #14790]

    time.rb: fix parsing time zone in iso8601

    * lib/time.rb (Time.xmlschema): the minute in time zone designator
      can be omitted together with the preceding colon.
       [Bug #14790]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@64148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 64148
Added by usa (Usaku NAKAMURA) 4 months ago

merge revision(s) 63512,63514: [Backport #14790]

time.rb: fix parsing time zone in iso8601

* lib/time.rb (Time.xmlschema): a colon in time zone designator
  can be omitted.   [Bug #14790]

time.rb: fix parsing time zone in iso8601

* lib/time.rb (Time.xmlschema): the minute in time zone designator
  can be omitted together with the preceding colon.
   [Bug #14790]

Revision 36045438
Added by nagachika (Tomoyuki Chikanaga) 4 months ago

merge revision(s) 63512,63514: [Backport #14790]

    time.rb: fix parsing time zone in iso8601

    * lib/time.rb (Time.xmlschema): a colon in time zone designator
      can be omitted.   [Bug #14790]

    time.rb: fix parsing time zone in iso8601

    * lib/time.rb (Time.xmlschema): the minute in time zone designator
      can be omitted together with the preceding colon.
       [Bug #14790]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 64431
Added by nagachika (Tomoyuki Chikanaga) 4 months ago

merge revision(s) 63512,63514: [Backport #14790]

time.rb: fix parsing time zone in iso8601

* lib/time.rb (Time.xmlschema): a colon in time zone designator
  can be omitted.   [Bug #14790]

time.rb: fix parsing time zone in iso8601

* lib/time.rb (Time.xmlschema): the minute in time zone designator
  can be omitted together with the preceding colon.
   [Bug #14790]

History

#1 [ruby-core:87277] Updated by Hanmac (Hans Mackowiak) 7 months ago

you mean the offset right?

https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators says that "±hhmm" is valid too in iso8601

so i think the bug is more in Time because the offset should be valid?

Time itself does print it as "+0200" on inspect

#2 Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r63512.


time.rb: fix parsing time zone in iso8601

  • lib/time.rb (Time.xmlschema): a colon in time zone designator can be omitted. [Bug #14790]

#3 Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED

#4 [ruby-core:87283] Updated by Quintasan (Michał Zając) 7 months ago

Yes, you are right. It was a bug after all but not in the way I originally thought :D.

Hanmac (Hans Mackowiak) wrote:

you mean the offset right?

https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators says that "±hhmm" is valid too in iso8601

so i think the bug is more in Time because the offset should be valid?

Time itself does print it as "+0200" on inspect

#5 [ruby-core:88231] Updated by usa (Usaku NAKAMURA) 4 months ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: DONE, 2.5: REQUIRED

ruby_2_4 r64148 merged revision(s) 63512,63514.

#6 [ruby-core:88527] Updated by nagachika (Tomoyuki Chikanaga) 4 months ago

  • Backport changed from 2.3: REQUIRED, 2.4: DONE, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: DONE, 2.5: DONE

ruby_2_5 r64431 merged revision(s) 63512,63514.

Also available in: Atom PDF