summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1994-10-14 06:19:03 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:30 +0900
commit29f237a8b1df650089b54447f070726c75706b6f (patch)
treee6ee836a39a5f2f1d433d6532de32471b655fb6d /time.c
parent173976c97c9426aa8d96e53aef6c0e570c5fdfda (diff)
version 0.54v0_54
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.54.tar.gz
Diffstat (limited to 'time.c')
-rw-r--r--time.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/time.c b/time.c
index 4289f35..eea9783 100644
--- a/time.c
+++ b/time.c
@@ -128,6 +128,7 @@ Ftime_at(class, time)
return time_new_internal(class, tp->tv_sec, tp->tv_usec);
}
+
static VALUE
Ftime_to_i(time)
VALUE time;
@@ -139,6 +140,16 @@ Ftime_to_i(time)
}
static VALUE
+Ftime_to_f(time)
+ VALUE time;
+{
+ struct time_object *tobj;
+
+ GetTimeval(time, tobj);
+ return float_new((double)tobj->tv.tv_sec+(double)tobj->tv.tv_usec/1000000);
+}
+
+static VALUE
Ftime_usec(time)
VALUE time;
{
@@ -516,6 +527,7 @@ Init_Time()
rb_define_single_method(C_Time, "times", Ftime_times, 0);
rb_define_method(C_Time, "to_i", Ftime_to_i, 0);
+ rb_define_method(C_Time, "to_f", Ftime_to_f, 0);
rb_define_method(C_Time, "<=>", Ftime_cmp, 1);
rb_define_method(C_Time, "hash", Ftime_hash, 0);