2021-07-06 15:14:47 -03:00
|
|
|
/*
|
2023-04-12 19:47:15 -03:00
|
|
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
2024-11-16 15:15:20 -03:00
|
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
2021-07-06 15:14:47 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
2024-11-18 13:58:51 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/DurationConstructor.h>
|
2024-11-24 16:12:27 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/InstantConstructor.h>
|
2024-11-24 19:23:31 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/Now.h>
|
2024-11-22 11:23:09 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
|
2024-11-23 20:00:05 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
|
2024-11-20 14:59:15 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDayConstructor.h>
|
2024-11-23 12:21:21 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainTimeConstructor.h>
|
2024-11-21 13:22:32 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainYearMonthConstructor.h>
|
2021-07-06 15:14:47 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/Temporal.h>
|
2024-11-24 22:42:47 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h>
|
2021-07-06 15:14:47 -03:00
|
|
|
|
|
|
|
|
namespace JS::Temporal {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(Temporal);
|
2023-11-19 05:45:05 -03:00
|
|
|
|
2021-07-06 15:14:47 -03:00
|
|
|
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
|
2022-08-15 20:20:49 -03:00
|
|
|
Temporal::Temporal(Realm& realm)
|
2023-04-12 19:47:15 -03:00
|
|
|
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
2021-07-06 15:14:47 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
void Temporal::initialize(Realm& realm)
|
2021-07-06 15:14:47 -03:00
|
|
|
{
|
2023-08-07 03:41:28 -03:00
|
|
|
Base::initialize(realm);
|
2021-07-06 15:33:20 -03:00
|
|
|
|
|
|
|
|
auto& vm = this->vm();
|
|
|
|
|
|
2024-11-16 15:15:20 -03:00
|
|
|
// 1.1.1 Temporal [ %Symbol.toStringTag% ], https://tc39.es/proposal-temporal/#sec-temporal-%symbol.tostringtag%
|
2023-08-08 13:25:57 -03:00
|
|
|
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), Attribute::Configurable);
|
2024-11-18 13:58:51 -03:00
|
|
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
2024-11-24 19:23:31 -03:00
|
|
|
define_direct_property(vm.names.Now, realm.create<Now>(realm), attr);
|
2024-11-18 13:58:51 -03:00
|
|
|
define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); });
|
2024-11-24 16:12:27 -03:00
|
|
|
define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); });
|
2024-11-22 11:23:09 -03:00
|
|
|
define_intrinsic_accessor(vm.names.PlainDate, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_date_constructor(); });
|
2024-11-23 20:00:05 -03:00
|
|
|
define_intrinsic_accessor(vm.names.PlainDateTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_date_time_constructor(); });
|
2024-11-20 14:59:15 -03:00
|
|
|
define_intrinsic_accessor(vm.names.PlainMonthDay, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_month_day_constructor(); });
|
2024-11-23 12:21:21 -03:00
|
|
|
define_intrinsic_accessor(vm.names.PlainTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_time_constructor(); });
|
2024-11-21 13:22:32 -03:00
|
|
|
define_intrinsic_accessor(vm.names.PlainYearMonth, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_year_month_constructor(); });
|
2024-11-24 22:42:47 -03:00
|
|
|
define_intrinsic_accessor(vm.names.ZonedDateTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_zoned_date_time_constructor(); });
|
2021-07-06 15:14:47 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|