mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibJS: Implement Temporal.PlainYearMonth.prototype.until/since
This commit is contained in:
parent
203269fae2
commit
cb5d1b5086
Notes:
github-actions[bot]
2024-11-22 18:56:30 +00:00
Author: https://github.com/trflynn89
Commit: cb5d1b5086
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2496
26 changed files with 1586 additions and 1 deletions
|
@ -8,7 +8,9 @@
|
|||
|
||||
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Temporal/Instant.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDate.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainTime.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
|
@ -52,4 +54,17 @@ bool iso_date_time_within_limits(ISODateTime iso_date_time)
|
|||
return true;
|
||||
}
|
||||
|
||||
// 5.5.7 BalanceISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond ), https://tc39.es/proposal-temporal/#sec-temporal-balanceisodatetime
|
||||
ISODateTime balance_iso_date_time(double year, double month, double day, double hour, double minute, double second, double millisecond, double microsecond, double nanosecond)
|
||||
{
|
||||
// 1. Let balancedTime be BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).
|
||||
auto balanced_time = balance_time(hour, minute, second, millisecond, microsecond, nanosecond);
|
||||
|
||||
// 2. Let balancedDate be BalanceISODate(year, month, day + balancedTime.[[Days]]).
|
||||
auto balanced_date = balance_iso_date(year, month, day + balanced_time.days);
|
||||
|
||||
// 3. Return CombineISODateAndTimeRecord(balancedDate, balancedTime).
|
||||
return combine_iso_date_and_time_record(balanced_date, balanced_time);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue