summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-13 23:51:16 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-13 23:51:16 +0000
commit4bf4ddb693b885a5ce9b9ad983c4743627ae29cc (patch)
tree1043eb3bd33ff94f689ab70f8153079c5be80d42 /time.c
parent49ab7b42383ecd1d8194e17f52c8e3f9273e1459 (diff)
downloadruby-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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/time.c b/time.c
index 70f0bb65ae..2d5edbe338 100644
--- a/time.c
+++ b/time.c
@@ -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;
}
/*