Project

General

Profile

Actions

Misc #19121

open

Time: utc offset argument's formats "+/-HH", "+/-HHMM", "+/-HHMMSS" are supported differently

Added by andrykonchin (Andrew Konchin) over 1 year ago. Updated over 1 year ago.

Status:
Open
Assignee:
-
[ruby-core:110705]

Description

I've noticed a strange difference between Ruby versions 2.7, 3.0 and 3.1.

The mentioned above formats are supported in Ruby 2.7 and Ruby 3.1 but aren't supported in Ruby 3.0.

So I am wondering whether supporting these formats is expected behaviour or a bug. In any case I would expect consistent behaviour in all the supported Ruby versions.

Ruby 2.7.4

Time.new(2000, 1, 1, 0, 0, 0, "+05") # => 2000-01-01 00:00:00 +0500
Time.new(2000, 1, 1, 0, 0, 0, "+0530") # => 2000-01-01 00:00:00 +0530
Time.new(2000, 1, 1, 0, 0, 0, "+053037") # => 2000-01-01 00:00:00 +0530

Ruby 3.0.4

Time.new(2000, 1, 1, 0, 0, 0, "+05")
#(irb):1:in `initialize': "+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset (ArgumentError)

Time.new(2000, 1, 1, 0, 0, 0, "+0530")
#(irb):2:in `initialize': "+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset (ArgumentError)

Time.new(2000, 1, 1, 0, 0, 0, "+053037")
#(irb):3:in `initialize': "+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset (ArgumentError)

Ruby 3.1.2

Time.new(2000, 1, 1, 0, 0, 0, "+05") # => 2000-01-01 00:00:00 +0500

Time.new(2000, 1, 1, 0, 0, 0, "+0530") # => 2000-01-01 00:00:00 +0530

Time.new(2000, 1, 1, 0, 0, 0, "+053037") # => 2000-01-01 00:00:00 +053037

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #17504: Allow UTC offset without colons per ISO-8601ClosedActions
Actions #1

Updated by andrykonchin (Andrew Konchin) over 1 year ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Is duplicate of Bug #17504: Allow UTC offset without colons per ISO-8601 added
Actions #3

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

3.0 seems partially backported.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0