From c9c94c2fee4abd471f0da2821c51e2b9421eaa95 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 13 Dec 2001 08:12:59 +0000 Subject: [PATCH] * 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 --- ChangeLog | 4 ++++ time.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2506760e9c..161b4f16c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 13 10:03:18 2001 Yukihiro Matsumoto + + * time.c (time_cmp): should handle Bignums. + Mon Dec 10 17:40:02 2001 K.Kosako * parse.y (str_extend): make up pushback call. 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)