summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-30 03:22:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-30 03:22:23 +0000
commitcaa3c880400e48ff22099f3c003e6ba5290f9b61 (patch)
tree8ea6753ed959e208591a98766cd517736b05cdc7 /time.c
parentadcab6c1bb711ba5f5b53073bdcb571ce28d26a2 (diff)
downloadruby-caa3c880400e48ff22099f3c003e6ba5290f9b61.tar.gz
* time.c (v2w): Normalize a rational value to an integer if possible.
[ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/time.c b/time.c
index c8f15bfc97..c01ca743d5 100644
--- a/time.c
+++ b/time.c
@@ -320,6 +320,11 @@ v2w_bignum(VALUE v)
static inline wideval_t
v2w(VALUE v)
{
+ if (RB_TYPE_P(v, T_RATIONAL)) {
+ if (RRATIONAL(v)->den != LONG2FIX(1))
+ return v;
+ v = RRATIONAL(v)->num;
+ }
#if WIDEVALUE_IS_WIDER
if (FIXNUM_P(v)) {
return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v);