Bug #1481
closedexact Time and inexact Time
Description
=begin
まつもと ゆきひろです
In message "Re: [ruby-dev:38484] Re: [Bug:1.9] exact Time and inexact Time"
on Sun, 17 May 2009 21:46:01 +0900, Tanaka Akira akr@fsij.org writes:
|Time#to_r を加えるのはあり得ると思います。
私もこちらに賛成します。
=end
Updated by mame (Yusuke Endoh) almost 16 years ago
=begin
遠藤です。
2009/05/18 9:05 Yukihiro Matsumoto matz@ruby-lang.org:
まつもと ゆきひろです
In message "Re: [ruby-dev:38484] Re: [Bug:1.9] exact Time and inexact Time"
on Sun, 17 May 2009 21:46:01 +0900, Tanaka Akira akr@fsij.org writes:|Time#to_r を加えるのはあり得ると思います。
私もこちらに賛成します。
それではパッチを書きました。
- Time#to_r を追加
- Time#- は常に Float を返す (1.9.1 と同じ挙動)
特に反対がなければコミットしようと思います。
Index: time.c¶
--- time.c (revision 23485)
+++ time.c (working copy)
@@ -2277,6 +2277,30 @@
/*
- call-seq:
-
-
time.to_r => Rational
-
-
-
- Returns the value of time as a rational number of seconds
-
- since the Epoch.
-
-
-
t = Time.now
-
-
-
p t.to_r #=> (8807170717088293/8388608)
-
-
-
- This method is intended to be used to get an accurate value
-
- representing nanoseconds from the Epoch. You can use this
-
- to convert time to another Epoch.
- */
+static VALUE
+time_to_r(VALUE time)
+{
- struct time_object *tobj;
- GetTimeval(time, tobj);
- return tobj->timev;
+}
+/*
-
- call-seq:
-
time.usec => int
-
time.tv_usec => int
@@ -2803,7 +2827,7 @@
struct time_object *tobj2;
GetTimeval(time2, tobj2);
-
return sub(tobj->timev, tobj2->timev);
-
return rb_Float(sub(tobj->timev, tobj2->timev));
}
return time_add(tobj, time2, -1);
}
@@ -3682,6 +3706,7 @@rb_define_method(rb_cTime, "to_i", time_to_i, 0);
rb_define_method(rb_cTime, "to_f", time_to_f, 0); -
rb_define_method(rb_cTime, "to_r", time_to_r, 0);
rb_define_method(rb_cTime, "<=>", time_cmp, 1);
rb_define_method(rb_cTime, "eql?", time_eql, 1);
rb_define_method(rb_cTime, "hash", time_hash, 0);
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by matz (Yukihiro Matsumoto) almost 16 years ago
- Status changed from Open to Closed
- ruby -v set to 1.9.1
=begin
redundant
=end