mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Make Date's tuple constructor correctly handle out-of-range arguments
Milliseconds need extra handling, but everything else just works now that mktime() handles this case.
This commit is contained in:
committed by
Andreas Kling
parent
5b9d43767c
commit
2191ec591f
@@ -195,6 +195,13 @@ Value DateConstructor::construct(Interpreter& interpreter, Function&)
|
||||
int seconds = arg_or(5, 0);
|
||||
int milliseconds = arg_or(6, 0);
|
||||
|
||||
seconds += milliseconds / 1000;
|
||||
milliseconds %= 1000;
|
||||
if (milliseconds < 0) {
|
||||
seconds -= 1;
|
||||
milliseconds += 1000;
|
||||
}
|
||||
|
||||
if (year >= 0 && year <= 99)
|
||||
year += 1900;
|
||||
int month = month_index + 1;
|
||||
|
||||
Reference in New Issue
Block a user