mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibJS: Implement most of GetTemporalRelativeToOption
Now that we have the Temporal.PlainDate object, we can flesh out this AO for such relative-to objects.
This commit is contained in:
parent
521638642f
commit
06593b1894
Notes:
github-actions[bot]
2024-11-23 13:47:14 +00:00
Author: https://github.com/trflynn89
Commit: 06593b1894
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2513
Reviewed-by: https://github.com/shannonbooth ✅
8 changed files with 189 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Temporal/Calendar.h>
|
||||
#include <LibJS/Runtime/Temporal/Instant.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDate.h>
|
||||
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
||||
|
@ -54,6 +55,19 @@ bool iso_date_time_within_limits(ISODateTime iso_date_time)
|
|||
return true;
|
||||
}
|
||||
|
||||
// 5.5.5 InterpretTemporalDateTimeFields ( calendar, fields, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-interprettemporaldatetimefields
|
||||
ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM& vm, StringView calendar, CalendarFields& fields, Overflow overflow)
|
||||
{
|
||||
// 1. Let isoDate be ? CalendarDateFromFields(calendar, fields, overflow).
|
||||
auto iso_date = TRY(calendar_date_from_fields(vm, calendar, fields, overflow));
|
||||
|
||||
// 2. Let time be ? RegulateTime(fields.[[Hour]], fields.[[Minute]], fields.[[Second]], fields.[[Millisecond]], fields.[[Microsecond]], fields.[[Nanosecond]], overflow).
|
||||
auto time = TRY(regulate_time(vm, *fields.hour, *fields.minute, *fields.second, *fields.millisecond, *fields.microsecond, *fields.nanosecond, overflow));
|
||||
|
||||
// 3. Return CombineISODateAndTimeRecord(isoDate, time).
|
||||
return combine_iso_date_and_time_record(iso_date, time);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue