mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
LibJS: Implement Temporal.TimeZone.prototype.toJSON()
This commit is contained in:
parent
8d00504ff2
commit
7f0fe352e2
3 changed files with 26 additions and 0 deletions
|
@ -24,6 +24,7 @@ void TimeZonePrototype::initialize(GlobalObject& global_object)
|
|||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(vm.names.toJSON, to_json, 0, attr);
|
||||
|
||||
// 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "Temporal.TimeZone"), Attribute::Configurable);
|
||||
|
@ -55,4 +56,14 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|||
return js_string(vm, time_zone->identifier());
|
||||
}
|
||||
|
||||
// 11.4.12 Temporal.TimeZone.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tojson
|
||||
JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
|
||||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
auto time_zone = vm.this_value(global_object);
|
||||
|
||||
// 2. Return ? ToString(timeZone).
|
||||
return js_string(vm, time_zone.to_string(global_object));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_json);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue