time.c: `1969-12-31 23:59:59` is a valid time.

But `mktime(3)` for the date returns `-1` which happen to be the
error value.
parent 8f09d8fe
......@@ -483,7 +483,17 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
nowsecs = mktime(&nowtime);
}
if (nowsecs == (time_t)-1) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time");
nowtime.tm_sec += 1;
if (timezone == MRB_TIMEZONE_UTC) {
nowsecs = timegm(&nowtime);
}
else {
nowsecs = mktime(&nowtime);
}
if (nowsecs != 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time");
}
nowsecs = (time_t)-1;
}
return time_alloc_time(mrb, nowsecs, ausec, timezone);
......
......@@ -267,7 +267,3 @@ assert('2000 times 500us make a second') do
end
assert_equal(0, t.usec)
end
assert('Time.gm with Dec 31 23:59:59 1969 raise ArgumentError') do
assert_raise(ArgumentError) {Time.gm(1969, 12, 31, 23, 59, 59)}
end
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