mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibJS: Port to_temporal_offset() to String
This commit is contained in:
parent
3aa3ab65b1
commit
a387b22599
Notes:
sideshowbarker
2024-07-17 03:05:16 +09:00
Author: https://github.com/linusg
Commit: a387b22599
Pull-request: https://github.com/SerenityOS/serenity/pull/17186
Reviewed-by: https://github.com/trflynn89 ✅
4 changed files with 9 additions and 9 deletions
|
@ -230,17 +230,17 @@ StringView negate_temporal_rounding_mode(StringView rounding_mode)
|
|||
}
|
||||
|
||||
// 13.8 ToTemporalOffset ( options, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloffset
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_offset(VM& vm, Object const* options, DeprecatedString const& fallback)
|
||||
ThrowCompletionOr<String> to_temporal_offset(VM& vm, Object const* options, StringView fallback)
|
||||
{
|
||||
// 1. If options is undefined, return fallback.
|
||||
if (options == nullptr)
|
||||
return fallback;
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8(fallback));
|
||||
|
||||
// 2. Return ? GetOption(options, "offset", "string", « "prefer", "use", "ignore", "reject" », fallback).
|
||||
auto option = TRY(get_option(vm, *options, vm.names.offset, OptionType::String, { "prefer"sv, "use"sv, "ignore"sv, "reject"sv }, fallback.view()));
|
||||
auto option = TRY(get_option(vm, *options, vm.names.offset, OptionType::String, { "prefer"sv, "use"sv, "ignore"sv, "reject"sv }, fallback));
|
||||
|
||||
VERIFY(option.is_string());
|
||||
return TRY(option.as_string().deprecated_string());
|
||||
return option.as_string().utf8_string();
|
||||
}
|
||||
|
||||
// 13.9 ToCalendarNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-tocalendarnameoption
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue