LibJS: Update Date AOs to use Temporal

Neglected to do this after the Temporal rewrite. This lets us eliminate
the duplicated GetUTCEpochNanoseconds definition in Temporal.
This commit is contained in:
Timothy Flynn 2025-02-28 11:54:54 -05:00 committed by Andreas Kling
commit ea52952774
Notes: github-actions[bot] 2025-03-01 13:50:51 +00:00
9 changed files with 47 additions and 56 deletions

View file

@ -7,6 +7,7 @@
*/
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Date.h>
#include <LibJS/Runtime/Temporal/Calendar.h>
#include <LibJS/Runtime/Temporal/Duration.h>
#include <LibJS/Runtime/Temporal/Instant.h>
@ -28,6 +29,19 @@ PlainDateTime::PlainDateTime(ISODateTime const& iso_date_time, String calendar,
{
}
// 5.5.2 TimeValueToISODateTimeRecord ( t ), https://tc39.es/proposal-temporal/#sec-temporal-timevaluetoisodatetimerecord
ISODateTime time_value_to_iso_date_time_record(double time_value)
{
// 1. Let isoDate be CreateISODateRecord((YearFromTime(t)), (MonthFromTime(t)) + 1, (DateFromTime(t))).
auto iso_date = create_iso_date_record(year_from_time(time_value), month_from_time(time_value) + 1, date_from_time(time_value));
// 2. Let time be CreateTimeRecord((HourFromTime(t)), (MinFromTime(t)), (SecFromTime(t)), (msFromTime(t)), 0, 0).
auto time = create_time_record(hour_from_time(time_value), min_from_time(time_value), sec_from_time(time_value), ms_from_time(time_value), 0, 0);
// 3. Return ISO Date-Time Record { [[ISODate]]: isoDate, [[Time]]: time }.
return { .iso_date = iso_date, .time = time };
}
// 5.5.3 CombineISODateAndTimeRecord ( isoDate, time ), https://tc39.es/proposal-temporal/#sec-temporal-combineisodateandtimerecord
ISODateTime combine_iso_date_and_time_record(ISODate iso_date, Time const& time)
{