1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:07:45 +00:00

LibJS: Port builtin_time_zone_get_offset_string_for() to String

This commit is contained in:
Linus Groh 2023-01-26 16:12:06 +00:00
parent 95becb22ef
commit bb0362ec3b
3 changed files with 4 additions and 4 deletions

View file

@ -394,13 +394,13 @@ ThrowCompletionOr<double> get_offset_nanoseconds_for(VM& vm, Value time_zone, In
} }
// 11.6.9 BuiltinTimeZoneGetOffsetStringFor ( timeZone, instant ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetoffsetstringfor // 11.6.9 BuiltinTimeZoneGetOffsetStringFor ( timeZone, instant ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetoffsetstringfor
ThrowCompletionOr<DeprecatedString> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant) ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant)
{ {
// 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant). // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(vm, time_zone, instant)); auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(vm, time_zone, instant));
// 2. Return ! FormatTimeZoneOffsetString(offsetNanoseconds). // 2. Return ! FormatTimeZoneOffsetString(offsetNanoseconds).
return MUST_OR_THROW_OOM(format_time_zone_offset_string(vm, offset_nanoseconds)).to_deprecated_string(); return MUST_OR_THROW_OOM(format_time_zone_offset_string(vm, offset_nanoseconds));
} }
// 11.6.10 BuiltinTimeZoneGetPlainDateTimeFor ( timeZone, instant, calendar ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetplaindatetimefor // 11.6.10 BuiltinTimeZoneGetPlainDateTimeFor ( timeZone, instant, calendar ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetplaindatetimefor

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<String> format_time_zone_offset_string(VM&, double offset_nano
ThrowCompletionOr<String> format_iso_time_zone_offset_string(VM&, double offset_nanoseconds); ThrowCompletionOr<String> format_iso_time_zone_offset_string(VM&, double offset_nanoseconds);
ThrowCompletionOr<Object*> to_temporal_time_zone(VM&, Value temporal_time_zone_like); ThrowCompletionOr<Object*> to_temporal_time_zone(VM&, Value temporal_time_zone_like);
ThrowCompletionOr<double> get_offset_nanoseconds_for(VM&, Value time_zone, Instant&); ThrowCompletionOr<double> get_offset_nanoseconds_for(VM&, Value time_zone, Instant&);
ThrowCompletionOr<DeprecatedString> builtin_time_zone_get_offset_string_for(VM&, Value time_zone, Instant&); ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM&, Value time_zone, Instant&);
ThrowCompletionOr<PlainDateTime*> builtin_time_zone_get_plain_date_time_for(VM&, Value time_zone, Instant&, Object& calendar); ThrowCompletionOr<PlainDateTime*> builtin_time_zone_get_plain_date_time_for(VM&, Value time_zone, Instant&, Object& calendar);
ThrowCompletionOr<Instant*> builtin_time_zone_get_instant_for(VM&, Value time_zone, PlainDateTime&, StringView disambiguation); ThrowCompletionOr<Instant*> builtin_time_zone_get_instant_for(VM&, Value time_zone, PlainDateTime&, StringView disambiguation);
ThrowCompletionOr<Instant*> disambiguate_possible_instants(VM&, MarkedVector<Instant*> const& possible_instants, Value time_zone, PlainDateTime&, StringView disambiguation); ThrowCompletionOr<Instant*> disambiguate_possible_instants(VM&, MarkedVector<Instant*> const& possible_instants, Value time_zone, PlainDateTime&, StringView disambiguation);

View file

@ -1369,7 +1369,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()))); MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())));
// 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset). // 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset).
MUST(fields->create_data_property_or_throw(vm.names.offset, PrimitiveString::create(vm, offset))); MUST(fields->create_data_property_or_throw(vm.names.offset, PrimitiveString::create(vm, move(offset))));
// 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone). // 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone).
MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone))); MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone)));