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
Actions
Like0
Like0Like0Like0