diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-13 18:25:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-13 18:37:36 +0900 |
commit | e9b93d67baf8a6add548b7e5c702665100e4b3c9 (patch) | |
tree | d68a42829a04c1e19aadb7b65c7bebf7afaed598 /timev.rb | |
parent | 4b15caee8fe7a5aaa52ed5a3ab2a3517c9206fd7 (diff) |
Positional and keyword arguments for timezone are exclusive
[Feature #17485]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4010
Diffstat (limited to 'timev.rb')
-rw-r--r-- | timev.rb | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -107,9 +107,19 @@ class Time # (t4-t3)/3600.0 #=> 2.466666666666667 # (t6-t5)/3600.0 #=> 1.95 # (t8-t7)/3600.0 #=> 13.416666666666666 - def initialize(year = (now = true), mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: zone) - zone = __builtin.arg!(:in) - return __builtin.time_init_now(zone) if now + def initialize(year = (now = true), mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil) + if zone + if __builtin.arg!(:in) + raise ArgumentError, "timezone argument given as positional and keyword arguments" + end + else + zone = __builtin.arg!(:in) + end + + if now + return __builtin.time_init_now(zone) + end + __builtin.time_init_args(year, mon, mday, hour, min, sec, zone) end end |