Project

General

Profile

Feature #17485

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

Currently, `Time.at` and `Time.now` accept a timezone as a keyword argument, but not `Time.new`. 
 This means minor arguments cannot be omitted for `Time.new`. 

 ```ruby 
 Time.new(2021, 1, 1, 0, 0, 0, "+09:00") #=> ok: 2021-01-01 00:00:00 +0900 
 Time.new(2021, 1, 1, "+09:00")            #=> bad: 2021-01-01 09:00:00 +0900 
 Time.new(2021, 1, "+09:00")               #=> bad: 2021-01-09 00:00:00 +0900 
 Time.new(2021, "+09:00")                  #=> ArgumentError (mon out of range) 
 ``` 

 Suggest that `Time.new` should also accept the `in:` timezone option. 

 ```ruby 
 Time.new(2021, 1, 1, in: "+09:00") #=> ok: 2021-01-01 00:00:00 +0900 
 Time.new(2021, in: "+09:00")         #=> ok: 2021-01-01 00:00:00 +0900 
 ``` 

 https://github.com/ruby/ruby/pull/4010

Back