Commit 995a329b authored by takkaw's avatar takkaw

fix Time about carry-up and carry-down

parent 8a988643
...@@ -263,12 +263,12 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone) ...@@ -263,12 +263,12 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone)
tm->sec = tsec; tm->sec = tsec;
tm->usec = (time_t)llround((sec - tm->sec) * 1.0e6 + usec); tm->usec = (time_t)llround((sec - tm->sec) * 1.0e6 + usec);
if (tm->usec < 0) { 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->usec -= sec2 * 1000000;
tm->sec += sec2; tm->sec += sec2;
} }
else if (tm->usec >= 1000000) { else if (tm->usec >= 1000000) {
long sec2 = (long)(usec / 1000000); long sec2 = (long)(tm->usec / 1000000);
tm->usec -= sec2 * 1000000; tm->usec -= sec2 * 1000000;
tm->sec += sec2; tm->sec += sec2;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment