[前][次][番号順一覧][スレッド一覧]

ruby-changes:69728

From: Koichi <ko1@a...>
Date: Mon, 15 Nov 2021 15:59:14 +0900 (JST)
Subject: [ruby-changes:69728] 2a3d5d661c (master): Use `Primitive.mandatory_only?` for `Time.at`

https://git.ruby-lang.org/ruby.git/commit/?id=2a3d5d661c

From 2a3d5d661ce2cadad50aa5d72b54e134da54f5f3 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Sat, 13 Nov 2021 07:44:46 +0900
Subject: Use `Primitive.mandatory_only?` for `Time.at`

---
 time.c   | 6 ++++++
 timev.rb | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/time.c b/time.c
index 44864ff748c..9c23089cfdd 100644
--- a/time.c
+++ b/time.c
@@ -2708,6 +2708,12 @@ time_s_at(rb_execution_context_t *ec, VALUE klass, VALUE time, VALUE subsec, VAL https://github.com/ruby/ruby/blob/trunk/time.c#L2708
     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",
diff --git a/timev.rb b/timev.rb
index a475fc482df..675b54faf64 100644
--- a/timev.rb
+++ b/timev.rb
@@ -268,7 +268,11 @@ class Time https://github.com/ruby/ruby/blob/trunk/timev.rb#L268
   # :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.
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]