Actions
Misc #19121
openTime: utc offset argument's formats "+/-HH", "+/-HHMM", "+/-HHMMSS" are supported differently
Status:
Open
Assignee:
-
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
Updated by andrykonchin (Andrew Konchin) about 2 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
- Is duplicate of Bug #17504: Allow UTC offset without colons per ISO-8601 added
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
3.0 seems partially backported.
Actions
Like0
Like0Like0Like0