summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-13 08:12:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-13 08:12:59 +0000
commitc9c94c2fee4abd471f0da2821c51e2b9421eaa95 (patch)
treeca012d58c49423fbf67fc32db46b1f9d960356a8 /time.c
parent03960ec8ff8a6e6d10ac127d6a7567cbd149c524 (diff)
* time.c (time_cmp): should handle Bignums.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/time.c b/time.c
index e6809e16f0..7cd87a26a4 100644
--- a/time.c
+++ b/time.c
@@ -500,6 +500,14 @@ time_cmp(time1, time2)
if (tobj1->tv.tv_sec > tobj2->tv.tv_sec) return INT2FIX(1);
return INT2FIX(-1);
}
+ if (TYPE(time2) == T_BIGNUM) {
+ double a = (double)tobj1->tv.tv_sec+(double)tobj1->tv.tv_usec/1e6;
+ double b = rb_big2dbl(time2);
+
+ if (a == b) return INT2FIX(0);
+ if (a > b) return INT2FIX(1);
+ if (a < b) return INT2FIX(-1);
+ }
i = NUM2LONG(time2);
if (tobj1->tv.tv_sec == i) {
if (tobj1->tv.tv_usec == 0)