mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:57:35 +00:00
LibJS: Implement Temporal.PlainMonthDay.prototype.toLocaleString()
This commit is contained in:
parent
ea44f33d5b
commit
5904c6bf18
3 changed files with 43 additions and 0 deletions
|
@ -34,6 +34,7 @@ void PlainMonthDayPrototype::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.toLocaleString, to_locale_string, 0, attr);
|
||||
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
||||
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
||||
}
|
||||
|
@ -123,6 +124,24 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string)
|
|||
return js_string(vm, *string);
|
||||
}
|
||||
|
||||
// 10.3.9 Temporal.PlainMonthDay.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tolocalestring
|
||||
// NOTE: This is the minimum toLocaleString implementation for engines without ECMA-402.
|
||||
JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_locale_string)
|
||||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = typed_this(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// 3. Return ? TemporalMonthDayToString(monthDay, "auto").
|
||||
auto string = temporal_month_day_to_string(global_object, *month_day, "auto"sv);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
return js_string(vm, *string);
|
||||
}
|
||||
|
||||
// 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof
|
||||
JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::value_of)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(month_code_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(day_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_locale_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(value_of);
|
||||
JS_DECLARE_NATIVE_FUNCTION(get_iso_fields);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue