diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-13 23:51:16 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-13 23:51:16 +0000 |
commit | 4bf4ddb693b885a5ce9b9ad983c4743627ae29cc (patch) | |
tree | 1043eb3bd33ff94f689ab70f8153079c5be80d42 /time.c | |
parent | 49ab7b42383ecd1d8194e17f52c8e3f9273e1459 (diff) | |
download | ruby-4bf4ddb693b885a5ce9b9ad983c4743627ae29cc.tar.gz |
* time.c (time_to_r): convert to rational if internal representation
is not rational.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2425,9 +2425,14 @@ static VALUE time_to_r(VALUE time) { struct time_object *tobj; + VALUE v; GetTimeval(time, tobj); - return rb_time_unmagnify(tobj->timexv); + v = rb_time_unmagnify(tobj->timexv); + if (TYPE(v) != T_RATIONAL) { + v = rb_convert_type(v, T_RATIONAL, "Rational", "to_r"); + } + return v; } /* |