mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
LibJS: Implement Temporal.Calendar.prototype.yearMonthFromFields()
This commit is contained in:
parent
c1c12497b5
commit
ed9d37bd40
10 changed files with 223 additions and 14 deletions
|
@ -237,18 +237,18 @@ bool is_valid_iso_date(i32 year, u8 month, u8 day)
|
|||
}
|
||||
|
||||
// 3.5.6 BalanceISODate ( year, month, day ), https://tc39.es/proposal-temporal/#sec-temporal-balanceisodate
|
||||
ISODate balance_iso_date(i32 year, i32 month, i32 day)
|
||||
ISODate balance_iso_date(double year_, double month_, double day)
|
||||
{
|
||||
// 1. Assert: year, month, and day are integers.
|
||||
|
||||
// 2. Let balancedYearMonth be ! BalanceISOYearMonth(year, month).
|
||||
auto balanced_year_month = balance_iso_year_month(year, month);
|
||||
auto balanced_year_month = balance_iso_year_month(year_, month_);
|
||||
|
||||
// 3. Set month to balancedYearMonth.[[Month]].
|
||||
month = balanced_year_month.month;
|
||||
auto month = balanced_year_month.month;
|
||||
|
||||
// 4. Set year to balancedYearMonth.[[Year]].
|
||||
year = balanced_year_month.year;
|
||||
auto year = balanced_year_month.year;
|
||||
|
||||
// 5. NOTE: To deal with negative numbers of days whose absolute value is greater than the number of days in a year, the following section subtracts years and adds days until the number of days is greater than −366 or −365.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue