mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 12:46:06 +00:00
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:
parent
5764eeab05
commit
ea52952774
Notes:
github-actions[bot]
2025-03-01 13:50:51 +00:00
Author: https://github.com/trflynn89
Commit: ea52952774
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3734
9 changed files with 47 additions and 56 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue