mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
LibJS: Support month and day arguments of Date.setFullYear
This commit is contained in:
parent
d48666489c
commit
ad40c5f9a9
1 changed files with 20 additions and 3 deletions
|
@ -128,10 +128,27 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_full_year)
|
||||||
auto new_year = vm.argument(0).to_i32(global_object);
|
auto new_year = vm.argument(0).to_i32(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
// FIXME: Support specifying new month and new day as well.
|
|
||||||
auto& datetime = this_object->datetime();
|
auto& datetime = this_object->datetime();
|
||||||
auto new_month = datetime.month();
|
|
||||||
auto new_day = datetime.day();
|
i32 new_month;
|
||||||
|
if (vm.argument_count() >= 2) {
|
||||||
|
new_month = vm.argument(1).to_i32(global_object);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
|
} else {
|
||||||
|
new_month = datetime.month();
|
||||||
|
}
|
||||||
|
|
||||||
|
i32 new_day;
|
||||||
|
if (vm.argument_count() >= 3) {
|
||||||
|
new_day = vm.argument(2).to_i32(global_object);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
|
} else {
|
||||||
|
new_day = datetime.day();
|
||||||
|
}
|
||||||
|
|
||||||
datetime.set_time(new_year, new_month, new_day, datetime.hour(), datetime.minute(), datetime.second());
|
datetime.set_time(new_year, new_month, new_day, datetime.hour(), datetime.minute(), datetime.second());
|
||||||
return Value { this_object->time() };
|
return Value { this_object->time() };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue