|
@@ -6,7 +6,9 @@
|
|
|
|
|
|
#include <AK/TypeCasts.h>
|
|
#include <AK/TypeCasts.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
+#include <LibJS/Runtime/Temporal/Calendar.h>
|
|
#include <LibJS/Runtime/Temporal/Instant.h>
|
|
#include <LibJS/Runtime/Temporal/Instant.h>
|
|
|
|
+#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
|
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
|
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
|
#include <LibJS/Runtime/Temporal/TimeZonePrototype.h>
|
|
#include <LibJS/Runtime/Temporal/TimeZonePrototype.h>
|
|
|
|
|
|
@@ -28,6 +30,7 @@ void TimeZonePrototype::initialize(GlobalObject& global_object)
|
|
define_native_accessor(vm.names.id, id_getter, {}, Attribute::Configurable);
|
|
define_native_accessor(vm.names.id, id_getter, {}, Attribute::Configurable);
|
|
define_native_function(vm.names.getOffsetNanosecondsFor, get_offset_nanoseconds_for, 1, attr);
|
|
define_native_function(vm.names.getOffsetNanosecondsFor, get_offset_nanoseconds_for, 1, attr);
|
|
define_native_function(vm.names.getOffsetStringFor, get_offset_string_for, 1, attr);
|
|
define_native_function(vm.names.getOffsetStringFor, get_offset_string_for, 1, attr);
|
|
|
|
+ define_native_function(vm.names.getPlainDateTimeFor, get_plain_date_time_for, 1, attr);
|
|
define_native_function(vm.names.toString, to_string, 0, attr);
|
|
define_native_function(vm.names.toString, to_string, 0, attr);
|
|
define_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
define_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
|
|
|
|
@@ -101,6 +104,26 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
|
|
return js_string(vm, move(*offset_string));
|
|
return js_string(vm, move(*offset_string));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 11.4.6 Temporal.TimeZone.prototype.getPlainDateTimeFor ( instant [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getplaindatetimefor
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_plain_date_time_for)
|
|
|
|
+{
|
|
|
|
+ // 1. Let timeZone be the this value.
|
|
|
|
+ auto time_zone = vm.this_value(global_object);
|
|
|
|
+
|
|
|
|
+ // 2. Set instant to ? ToTemporalInstant(instant).
|
|
|
|
+ auto* instant = to_temporal_instant(global_object, vm.argument(0));
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ // 3. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
|
|
|
|
+ auto* calendar = to_temporal_calendar_with_iso_default(global_object, vm.argument(1));
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ // 4. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
|
|
|
|
+ return builtin_time_zone_get_plain_date_time_for(global_object, time_zone, *instant, *calendar);
|
|
|
|
+}
|
|
|
|
+
|
|
// 11.4.11 Temporal.TimeZone.prototype.toString ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tostring
|
|
// 11.4.11 Temporal.TimeZone.prototype.toString ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tostring
|
|
JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|
JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|
{
|
|
{
|