mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use Primitive.mandatory_only?
for Time.at
This commit is contained in:
parent
dde010c974
commit
2a3d5d661c
Notes:
git
2021-11-15 15:59:18 +09:00
2 changed files with 11 additions and 1 deletions
6
time.c
6
time.c
|
@ -2708,6 +2708,12 @@ time_s_at(rb_execution_context_t *ec, VALUE klass, VALUE time, VALUE subsec, VAL
|
|||
return t;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
time_s_at1(rb_execution_context_t *ec, VALUE klass, VALUE time)
|
||||
{
|
||||
return time_s_at(ec, klass, time, Qfalse, ID2SYM(id_microsecond), Qnil);
|
||||
}
|
||||
|
||||
static const char months[][4] = {
|
||||
"jan", "feb", "mar", "apr", "may", "jun",
|
||||
"jul", "aug", "sep", "oct", "nov", "dec",
|
||||
|
|
6
timev.rb
6
timev.rb
|
@ -268,7 +268,11 @@ class Time
|
|||
# :include: doc/time/in.rdoc
|
||||
#
|
||||
def self.at(time, subsec = false, unit = :microsecond, in: nil)
|
||||
Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in))
|
||||
if Primitive.mandatory_only?
|
||||
Primitive.time_s_at1(time)
|
||||
else
|
||||
Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in))
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a new \Time object based the on given arguments.
|
||||
|
|
Loading…
Add table
Reference in a new issue