mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Positional and keyword arguments for timezone are exclusive
[Feature #17485]
This commit is contained in:
parent
4b15caee8f
commit
e9b93d67ba
Notes:
git
2021-01-13 20:41:34 +09:00
2 changed files with 14 additions and 3 deletions
16
timev.rb
16
timev.rb
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue