ruby-changes:69681
From: Nobuyoshi <ko1@a...>
Date: Wed, 10 Nov 2021 17:42:36 +0900 (JST)
Subject: [ruby-changes:69681] 83bdc2f00c (master): Simplify default values of `Time.at` [Bug #18293]
https://git.ruby-lang.org/ruby.git/commit/?id=83bdc2f00c From 83bdc2f00c4565a091d88399e5a315a96f6afed6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 9 Nov 2021 15:12:02 +0900 Subject: Simplify default values of `Time.at` [Bug #18293] --- time.c | 6 +++--- timev.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/time.c b/time.c index 6fa4047e297..9ecc09347cd 100644 --- a/time.c +++ b/time.c @@ -2678,13 +2678,13 @@ get_scale(VALUE unit) https://github.com/ruby/ruby/blob/trunk/time.c#L2678 } static VALUE -time_s_at(rb_execution_context_t *ec, VALUE klass, VALUE time, VALUE subsec, VALUE unit, VALUE zone, VALUE nosubsec, VALUE nounit) +time_s_at(rb_execution_context_t *ec, VALUE klass, VALUE time, VALUE subsec, VALUE unit, VALUE zone) { VALUE t; wideval_t timew; - if (!RTEST(nosubsec)) { - int scale = !RTEST(nounit) ? get_scale(unit) : 1000000; + if (!NIL_P(subsec)) { + int scale = get_scale(unit); time = num_exact(time); t = num_exact(subsec); timew = wadd(rb_time_magnify(v2w(time)), wmulquoll(v2w(t), TIME_SCALE, scale)); diff --git a/timev.rb b/timev.rb index 1be675df35d..b73d8c8cc0a 100644 --- a/timev.rb +++ b/timev.rb @@ -267,8 +267,8 @@ class Time https://github.com/ruby/ruby/blob/trunk/timev.rb#L267 # :include: doc/time/nsec.rdoc # :include: doc/time/in.rdoc # - def self.at(time, subsec = (nosubsec = true), unit = (nounit = true), in: nil) - __builtin.time_s_at(time, subsec, unit, __builtin.arg!(:in), nosubsec, nounit) + def self.at(time, subsec = nil, unit = :microsecond, in: nil) + __builtin.time_s_at(time, subsec, unit, __builtin.arg!(:in)) end # Returns a new \Time object based the on given arguments. -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/