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