1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibJS: Implement the Intl.RelativeTimeFormat constructor

This commit is contained in:
Timothy Flynn 2022-01-25 11:50:14 -05:00 committed by Linus Groh
parent 79fdec85de
commit a2e31ed736
4 changed files with 168 additions and 1 deletions

View file

@ -38,13 +38,17 @@ ThrowCompletionOr<Value> RelativeTimeFormatConstructor::call()
// 17.2.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat
ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto& global_object = this->global_object();
auto locales = vm.argument(0);
auto options = vm.argument(1);
// 2. Let relativeTimeFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%RelativeTimeFormat.prototype%", « [[InitializedRelativeTimeFormat]], [[Locale]], [[DataLocale]], [[Style]], [[Numeric]], [[NumberFormat]], [[NumberingSystem]], [[PluralRules]] »).
auto* relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(global_object, new_target, &GlobalObject::intl_relative_time_format_prototype));
// 3. Return ? InitializeRelativeTimeFormat(relativeTimeFormat, locales, options).
return relative_time_format;
return TRY(initialize_relative_time_format(global_object, *relative_time_format, locales, options));
}
}