summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time
diff options
context:
space:
mode:
authortakkaw <[email protected]>2019-01-26 23:19:53 +0900
committertakkaw <[email protected]>2019-01-26 23:19:53 +0900
commit995a329bf4983beb1322c2e2c4399c11bdb852fa (patch)
tree161492459a1df823270aaf6dcb438382ab78efa5 /mrbgems/mruby-time
parent8a988643e84d290777a00907e3db1f8ca8940b05 (diff)
downloadmruby-995a329bf4983beb1322c2e2c4399c11bdb852fa.tar.gz
mruby-995a329bf4983beb1322c2e2c4399c11bdb852fa.zip
fix Time about carry-up and carry-down
Diffstat (limited to 'mrbgems/mruby-time')
-rw-r--r--mrbgems/mruby-time/src/time.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index c3a0ac435..d70fb442c 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -263,12 +263,12 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone)
tm->sec = tsec;
tm->usec = (time_t)llround((sec - tm->sec) * 1.0e6 + usec);
if (tm->usec < 0) {
- long sec2 = (long)NDIV(usec,1000000); /* negative div */
+ long sec2 = (long)NDIV(tm->usec,1000000); /* negative div */
tm->usec -= sec2 * 1000000;
tm->sec += sec2;
}
else if (tm->usec >= 1000000) {
- long sec2 = (long)(usec / 1000000);
+ long sec2 = (long)(tm->usec / 1000000);
tm->usec -= sec2 * 1000000;
tm->sec += sec2;
}