mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:47:36 +00:00
LibJS: Account for differences in month representations (0-11 vs 1-12)
Since DateTime stores months as 1 to 12, while JS accepts months as 0 to 11, we have to account for the difference (by subtracting or adding 1) where appropriate.
This commit is contained in:
parent
b893963651
commit
59034554a4
2 changed files with 6 additions and 6 deletions
|
@ -169,14 +169,14 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_full_year)
|
|||
}
|
||||
auto new_year = new_year_value.as_i32();
|
||||
|
||||
auto new_month_value = arg_or(1, datetime.month());
|
||||
auto new_month_value = arg_or(1, datetime.month() - 1);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (!new_month_value.is_finite_number()) {
|
||||
this_object->set_is_invalid(true);
|
||||
return js_nan();
|
||||
}
|
||||
auto new_month = new_month_value.as_i32();
|
||||
auto new_month = new_month_value.as_i32() + 1; // JS Months: 0 - 11, DateTime months: 1-12
|
||||
|
||||
auto new_day_value = arg_or(2, datetime.day());
|
||||
if (vm.exception())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue