mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
LibJS: Implement Temporal.Now.plainDate()
...and ten required AOs we didn't have yet: - BalanceISODate - BalanceISODateTime - BalanceISOYearMonth - BalanceTime - BuiltinTimeZoneGetPlainDateTimeFor - GetISOPartsFromEpoch - GetOffsetNanosecondsFor - ParseTemporalTimeZone - SystemDateTime - ToTemporalTimeZone
This commit is contained in:
parent
5512ff79f0
commit
c303bbde54
18 changed files with 507 additions and 1 deletions
26
Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp
Normal file
26
Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Temporal/PlainYearMonth.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
// 9.5.5 BalanceISOYearMonth ( year, month ), https://tc39.es/proposal-temporal/#sec-temporal-balanceisoyearmonth
|
||||
ISOYearMonth balance_iso_year_month(i32 year, i32 month)
|
||||
{
|
||||
// 1. Assert: year and month are integers.
|
||||
|
||||
// 2. Set year to year + floor((month - 1) / 12).
|
||||
year += (month - 1) / 12;
|
||||
|
||||
// 3. Set month to (month − 1) modulo 12 + 1.
|
||||
month = (month - 1) % 12 + 1;
|
||||
|
||||
// 4. Return the new Record { [[Year]]: year, [[Month]]: month }.
|
||||
return ISOYearMonth { .year = year, .month = static_cast<u8>(month) };
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue