Commit 06a946ab authored by cremno's avatar cremno

mruby-time: fix check of `mktime`'s return value

>If the calendar time cannot be represented, the function returns the
value (time_t)(-1).
http://www.iso-9899.info/n1256.html#7.23.2.3p3
parent 8b5cbe2f
...@@ -293,7 +293,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday, ...@@ -293,7 +293,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
else { else {
nowsecs = mktime(&nowtime); nowsecs = mktime(&nowtime);
} }
if (nowsecs < 0) { if (nowsecs == (time_t)-1) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time."); mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time.");
} }
......
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