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>
|
2021-07-06 15:14:47 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
2021-07-14 17:01:12 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/CalendarConstructor.h>
|
2021-07-15 19:20:43 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/DurationConstructor.h>
|
2021-07-07 13:41:37 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/InstantConstructor.h>
|
2021-07-06 15:33:20 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/Now.h>
|
2021-07-18 18:29:26 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
|
2021-07-22 15:47:07 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
|
2021-08-14 19:54:24 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDayConstructor.h>
|
2021-07-28 14:36:52 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainTimeConstructor.h>
|
2021-08-07 18:40:32 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/PlainYearMonthConstructor.h>
|
2021-07-06 15:14:47 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/Temporal.h>
|
2021-07-06 19:53:27 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
|
2021-08-01 13:20:11 -03:00
|
|
|
#include <LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h>
|
2021-07-06 15:14:47 -03:00
|
|
|
|
|
|
|
|
namespace JS::Temporal {
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
2021-07-27 14:47:23 -03:00
|
|
|
// 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@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);
|
2021-07-27 14:47:23 -03:00
|
|
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
2023-08-13 08:05:26 -03:00
|
|
|
define_direct_property(vm.names.Now, heap().allocate<Now>(realm, realm), attr);
|
2022-11-24 11:43:53 -03:00
|
|
|
define_intrinsic_accessor(vm.names.Calendar, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_calendar_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.PlainDate, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_date_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.PlainDateTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_date_time_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.PlainMonthDay, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_month_day_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.PlainTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_time_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.PlainYearMonth, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_year_month_constructor(); });
|
|
|
|
|
define_intrinsic_accessor(vm.names.TimeZone, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_time_zone_constructor(); });
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|