summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-18 08:54:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-18 08:54:01 +0000
commit3326cc9e053475a123b475ab2b17d9dcfd4aef88 (patch)
tree587bd457fd10c42896432e087864f0aac7eca23e /time.c
parent5c8d6f1bc36f676de37caa349ebf62913302ebfd (diff)
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896] * time.c (time_add): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/time.c b/time.c
index fa33798..a1f9639 100644
--- a/time.c
+++ b/time.c
@@ -194,7 +194,7 @@ time_timeval(time, interval)
if (f != t.tv_sec) {
rb_raise(rb_eRangeError, "%f out of Time range", RFLOAT(time)->value);
}
- t.tv_usec = (time_t)(d*1e6);
+ t.tv_usec = (time_t)(d*1e6+0.5);
}
break;
@@ -1287,7 +1287,7 @@ time_add(tobj, offset, sign)
if (f != (double)sec_off)
rb_raise(rb_eRangeError, "time %s %f out of Time range",
sign < 0 ? "-" : "+", v);
- usec_off = (time_t)(d*1e6);
+ usec_off = (time_t)(d*1e6+0.5);
if (sign < 0) {
sec = tobj->tv.tv_sec - sec_off;