From 41baf125f21e3fd49a7849e4b8bbf99e06a31b9e Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Tue, 5 Jun 2012 08:58:50 +0900 Subject: Time#- should return time if operand is a number --- src/time.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/time.c b/src/time.c index 24d86bc33..862ff57a9 100644 --- a/src/time.c +++ b/src/time.c @@ -363,8 +363,11 @@ mrb_time_minus(mrb_state *mrb, mrb_value self) return mrb_float_value(f); } else { - mrb_get_args(mrb, "f", &f); - return mrb_time_make(mrb, mrb_obj_class(mrb, self), f, tm->timezone); + mrb_float f, f2; + mrb_get_args(mrb, "f", &f2); + + f = ((mrb_float)tm->sec + (mrb_float)tm->usec/1.0e6); + return mrb_time_make(mrb, mrb_obj_class(mrb, self), f-f2, tm->timezone); } } -- cgit v1.2.3