mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:37:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -156,7 +156,7 @@ ThrowCompletionOr<Value> get_option(VM& vm, Object const& options, PropertyKey c
|
|||
}
|
||||
|
||||
// 13.4 ToTemporalOverflow ( options ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloverflow
|
||||
ThrowCompletionOr<String> to_temporal_overflow(VM& vm, Object const* options)
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_overflow(VM& vm, Object const* options)
|
||||
{
|
||||
// 1. If options is undefined, return "constrain".
|
||||
if (options == nullptr)
|
||||
|
@ -170,7 +170,7 @@ ThrowCompletionOr<String> to_temporal_overflow(VM& vm, Object const* options)
|
|||
}
|
||||
|
||||
// 13.5 ToTemporalDisambiguation ( options ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaldisambiguation
|
||||
ThrowCompletionOr<String> to_temporal_disambiguation(VM& vm, Object const* options)
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_disambiguation(VM& vm, Object const* options)
|
||||
{
|
||||
// 1. If options is undefined, return "compatible".
|
||||
if (options == nullptr)
|
||||
|
@ -184,7 +184,7 @@ ThrowCompletionOr<String> to_temporal_disambiguation(VM& vm, Object const* optio
|
|||
}
|
||||
|
||||
// 13.6 ToTemporalRoundingMode ( normalizedOptions, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalroundingmode
|
||||
ThrowCompletionOr<String> to_temporal_rounding_mode(VM& vm, Object const& normalized_options, String const& fallback)
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_rounding_mode(VM& vm, Object const& normalized_options, DeprecatedString const& fallback)
|
||||
{
|
||||
// 1. Return ? GetOption(normalizedOptions, "roundingMode", "string", « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », fallback).
|
||||
auto option = TRY(get_option(
|
||||
|
@ -207,7 +207,7 @@ ThrowCompletionOr<String> to_temporal_rounding_mode(VM& vm, Object const& normal
|
|||
}
|
||||
|
||||
// 13.7 NegateTemporalRoundingMode ( roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-negatetemporalroundingmode
|
||||
StringView negate_temporal_rounding_mode(String const& rounding_mode)
|
||||
StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode)
|
||||
{
|
||||
// 1. If roundingMode is "ceil", return "floor".
|
||||
if (rounding_mode == "ceil"sv)
|
||||
|
@ -230,7 +230,7 @@ StringView negate_temporal_rounding_mode(String const& rounding_mode)
|
|||
}
|
||||
|
||||
// 13.8 ToTemporalOffset ( options, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloffset
|
||||
ThrowCompletionOr<String> to_temporal_offset(VM& vm, Object const* options, String const& fallback)
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_offset(VM& vm, Object const* options, DeprecatedString const& fallback)
|
||||
{
|
||||
// 1. If options is undefined, return fallback.
|
||||
if (options == nullptr)
|
||||
|
@ -244,7 +244,7 @@ ThrowCompletionOr<String> to_temporal_offset(VM& vm, Object const* options, Stri
|
|||
}
|
||||
|
||||
// 13.9 ToCalendarNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-tocalendarnameoption
|
||||
ThrowCompletionOr<String> to_calendar_name_option(VM& vm, Object const& normalized_options)
|
||||
ThrowCompletionOr<DeprecatedString> to_calendar_name_option(VM& vm, Object const& normalized_options)
|
||||
{
|
||||
// 1. Return ? GetOption(normalizedOptions, "calendarName", "string", « "auto", "always", "never", "critical" », "auto").
|
||||
auto option = TRY(get_option(vm, normalized_options, vm.names.calendarName, OptionType::String, { "auto"sv, "always"sv, "never"sv, "critical"sv }, "auto"sv));
|
||||
|
@ -254,7 +254,7 @@ ThrowCompletionOr<String> to_calendar_name_option(VM& vm, Object const& normaliz
|
|||
}
|
||||
|
||||
// 13.10 ToTimeZoneNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-totimezonenameoption
|
||||
ThrowCompletionOr<String> to_time_zone_name_option(VM& vm, Object const& normalized_options)
|
||||
ThrowCompletionOr<DeprecatedString> to_time_zone_name_option(VM& vm, Object const& normalized_options)
|
||||
{
|
||||
// 1. Return ? GetOption(normalizedOptions, "timeZoneName", "string", « "auto", "never", "critical" », "auto").
|
||||
auto option = TRY(get_option(vm, normalized_options, vm.names.timeZoneName, OptionType::String, { "auto"sv, "never"sv, "critical"sv }, "auto"sv));
|
||||
|
@ -264,7 +264,7 @@ ThrowCompletionOr<String> to_time_zone_name_option(VM& vm, Object const& normali
|
|||
}
|
||||
|
||||
// 13.11 ToShowOffsetOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-toshowoffsetoption
|
||||
ThrowCompletionOr<String> to_show_offset_option(VM& vm, Object const& normalized_options)
|
||||
ThrowCompletionOr<DeprecatedString> to_show_offset_option(VM& vm, Object const& normalized_options)
|
||||
{
|
||||
// 1. Return ? GetOption(normalizedOptions, "offset", "string", « "auto", "never" », "auto").
|
||||
auto option = TRY(get_option(vm, normalized_options, vm.names.offset, OptionType::String, { "auto"sv, "never"sv }, "auto"sv));
|
||||
|
@ -458,7 +458,7 @@ static Vector<TemporalUnit> temporal_units = {
|
|||
};
|
||||
|
||||
// 13.15 GetTemporalUnit ( normalizedOptions, key, unitGroup, default [ , extraValues ] ), https://tc39.es/proposal-temporal/#sec-temporal-gettemporalunit
|
||||
ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& normalized_options, PropertyKey const& key, UnitGroup unit_group, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values)
|
||||
ThrowCompletionOr<Optional<DeprecatedString>> get_temporal_unit(VM& vm, Object const& normalized_options, PropertyKey const& key, UnitGroup unit_group, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values)
|
||||
{
|
||||
// 1. Let singularNames be a new empty List.
|
||||
Vector<StringView> singular_names;
|
||||
|
@ -527,10 +527,10 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& norm
|
|||
|
||||
// 10. If value is undefined and default is required, throw a RangeError exception.
|
||||
if (option_value.is_undefined() && default_.has<TemporalUnitRequired>())
|
||||
return vm.throw_completion<RangeError>(ErrorType::IsUndefined, String::formatted("{} option value", key.as_string()));
|
||||
return vm.throw_completion<RangeError>(ErrorType::IsUndefined, DeprecatedString::formatted("{} option value", key.as_string()));
|
||||
|
||||
Optional<String> value = option_value.is_undefined()
|
||||
? Optional<String> {}
|
||||
Optional<DeprecatedString> value = option_value.is_undefined()
|
||||
? Optional<DeprecatedString> {}
|
||||
: option_value.as_string().string();
|
||||
|
||||
// 11. If value is listed in the Plural column of Table 13, then
|
||||
|
@ -735,7 +735,7 @@ StringView larger_of_two_temporal_units(StringView unit1, StringView unit2)
|
|||
}
|
||||
|
||||
// 13.18 MergeLargestUnitOption ( options, largestUnit ), https://tc39.es/proposal-temporal/#sec-temporal-mergelargestunitoption
|
||||
ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& options, String largest_unit)
|
||||
ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& options, DeprecatedString largest_unit)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -824,7 +824,7 @@ ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(VM& vm, Object&
|
|||
}
|
||||
|
||||
// 13.21 FormatSecondsStringPart ( second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-formatsecondsstringpart
|
||||
String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision)
|
||||
DeprecatedString format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision)
|
||||
{
|
||||
// 1. Assert: second, millisecond, microsecond, and nanosecond are integers.
|
||||
|
||||
|
@ -834,15 +834,15 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u
|
|||
|
||||
// 2. If precision is "minute", return "".
|
||||
if (precision.has<StringView>() && precision.get<StringView>() == "minute"sv)
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 3. Let secondsString be the string-concatenation of the code unit 0x003A (COLON) and ToZeroPaddedDecimalString(second, 2).
|
||||
auto seconds_string = String::formatted(":{:02}", second);
|
||||
auto seconds_string = DeprecatedString::formatted(":{:02}", second);
|
||||
|
||||
// 4. Let fraction be millisecond × 10^6 + microsecond × 10^3 + nanosecond.
|
||||
u32 fraction = millisecond * 1'000'000 + microsecond * 1'000 + nanosecond;
|
||||
|
||||
String fraction_string;
|
||||
DeprecatedString fraction_string;
|
||||
|
||||
// 5. If precision is "auto", then
|
||||
if (precision.has<StringView>() && precision.get<StringView>() == "auto"sv) {
|
||||
|
@ -851,7 +851,7 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u
|
|||
return seconds_string;
|
||||
|
||||
// b. Set fraction to ToZeroPaddedDecimalString(fraction, 9).
|
||||
fraction_string = String::formatted("{:09}", fraction);
|
||||
fraction_string = DeprecatedString::formatted("{:09}", fraction);
|
||||
|
||||
// c. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
|
||||
fraction_string = fraction_string.trim("0"sv, TrimMode::Right);
|
||||
|
@ -863,14 +863,14 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u
|
|||
return seconds_string;
|
||||
|
||||
// b. Set fraction to ToZeroPaddedDecimalString(fraction, 9)
|
||||
fraction_string = String::formatted("{:09}", fraction);
|
||||
fraction_string = DeprecatedString::formatted("{:09}", fraction);
|
||||
|
||||
// c. Set fraction to the substring of fraction from 0 to precision.
|
||||
fraction_string = fraction_string.substring(0, precision.get<u8>());
|
||||
}
|
||||
|
||||
// 7. Return the string-concatenation of secondsString, the code unit 0x002E (FULL STOP), and fraction.
|
||||
return String::formatted("{}.{}", seconds_string, fraction_string);
|
||||
return DeprecatedString::formatted("{}.{}", seconds_string, fraction_string);
|
||||
}
|
||||
|
||||
// 13.23 GetUnsignedRoundingMode ( roundingMode, isNegative ), https://tc39.es/proposal-temporal/#sec-temporal-getunsignedroundingmode
|
||||
|
@ -1225,11 +1225,11 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
|
|||
auto f_seconds = parse_result.time_fraction;
|
||||
|
||||
// 5. If the first code point of year is U+2212 (MINUS SIGN), replace the first code point with U+002D (HYPHEN-MINUS).
|
||||
Optional<String> normalized_year;
|
||||
Optional<DeprecatedString> normalized_year;
|
||||
if (year.has_value()) {
|
||||
normalized_year = year->starts_with("\xE2\x88\x92"sv)
|
||||
? String::formatted("-{}", year->substring_view(3))
|
||||
: String { *year };
|
||||
? DeprecatedString::formatted("-{}", year->substring_view(3))
|
||||
: DeprecatedString { *year };
|
||||
}
|
||||
|
||||
// 6. Let yearMV be ! ToIntegerOrInfinity(CodePointsToString(year)).
|
||||
|
@ -1272,7 +1272,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
|
|||
auto f_seconds_digits = f_seconds->substring_view(1);
|
||||
|
||||
// b. Let fSecondsDigitsExtended be the string-concatenation of fSecondsDigits and "000000000".
|
||||
auto f_seconds_digits_extended = String::formatted("{}000000000", f_seconds_digits);
|
||||
auto f_seconds_digits_extended = DeprecatedString::formatted("{}000000000", f_seconds_digits);
|
||||
|
||||
// c. Let millisecond be the substring of fSecondsDigitsExtended from 0 to 3.
|
||||
auto millisecond = f_seconds_digits_extended.substring(0, 3);
|
||||
|
@ -1342,7 +1342,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
|
|||
}
|
||||
|
||||
// 23. Let calendar be undefined.
|
||||
Optional<String> calendar;
|
||||
Optional<DeprecatedString> calendar;
|
||||
|
||||
// 24. For each Annotation Parse Node annotation contained within parseResult, do
|
||||
for (auto const& annotation : parse_result.annotations) {
|
||||
|
@ -1373,7 +1373,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
|
|||
}
|
||||
|
||||
// 13.29 ParseTemporalInstantString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalinstantstring
|
||||
ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. If ParseText(StringToCodePoints(isoString), TemporalInstantString) is a List of errors, throw a RangeError exception.
|
||||
auto parse_result = parse_iso8601(Production::TemporalInstantString, iso_string);
|
||||
|
@ -1384,7 +1384,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String
|
|||
auto result = TRY(parse_iso_date_time(vm, *parse_result));
|
||||
|
||||
// 3. Let offsetString be result.[[TimeZone]].[[OffsetString]].
|
||||
Optional<String> offset_string = result.time_zone.offset_string;
|
||||
Optional<DeprecatedString> offset_string = result.time_zone.offset_string;
|
||||
|
||||
// 4. If result.[[TimeZone]].[[Z]] is true, then
|
||||
if (result.time_zone.z) {
|
||||
|
@ -1400,7 +1400,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String
|
|||
}
|
||||
|
||||
// 13.30 ParseTemporalZonedDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalzoneddatetimestring
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. If ParseText(StringToCodePoints(isoString), TemporalZonedDateTimeString) is a List of errors, throw a RangeError exception.
|
||||
auto parse_result = parse_iso8601(Production::TemporalZonedDateTimeString, iso_string);
|
||||
|
@ -1412,7 +1412,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, Str
|
|||
}
|
||||
|
||||
// 13.31 ParseTemporalCalendarString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalcalendarstring
|
||||
ThrowCompletionOr<String> parse_temporal_calendar_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<DeprecatedString> parse_temporal_calendar_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be Completion(ParseISODateTime(isoString)).
|
||||
auto parse_result_completion = parse_iso_date_time(vm, iso_string);
|
||||
|
@ -1444,7 +1444,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(VM& vm, String const& i
|
|||
}
|
||||
|
||||
// 13.32 ParseTemporalDateString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatestring
|
||||
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parts be ? ParseTemporalDateTimeString(isoString).
|
||||
auto parts = TRY(parse_temporal_date_time_string(vm, iso_string));
|
||||
|
@ -1454,7 +1454,7 @@ ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, String const&
|
|||
}
|
||||
|
||||
// 13.33 ParseTemporalDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatetimestring
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalDateTimeString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string);
|
||||
|
@ -1472,7 +1472,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, String co
|
|||
}
|
||||
|
||||
// 13.34 ParseTemporalDurationString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldurationstring
|
||||
ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let duration be ParseText(StringToCodePoints(isoString), TemporalDurationString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalDurationString, iso_string);
|
||||
|
@ -1608,7 +1608,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String
|
|||
}
|
||||
|
||||
// 13.35 ParseTemporalMonthDayString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalmonthdaystring
|
||||
ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalMonthDayString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalMonthDayString, iso_string);
|
||||
|
@ -1638,7 +1638,7 @@ ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, Stri
|
|||
}
|
||||
|
||||
// 13.36 ParseTemporalRelativeToString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalrelativetostring
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalDateTimeString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string);
|
||||
|
@ -1656,7 +1656,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, String
|
|||
}
|
||||
|
||||
// 13.37 ParseTemporalTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimestring
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalTimeString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalTimeString, iso_string);
|
||||
|
@ -1677,7 +1677,7 @@ ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, String const&
|
|||
}
|
||||
|
||||
// 13.38 ParseTemporalTimeZoneString ( timeZoneString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimezonestring
|
||||
ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, String const& time_zone_string)
|
||||
ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, DeprecatedString const& time_zone_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(timeZoneString), TimeZoneIdentifier).
|
||||
auto parse_result = parse_iso8601(Production::TimeZoneIdentifier, time_zone_string);
|
||||
|
@ -1703,7 +1703,7 @@ ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, Stri
|
|||
}
|
||||
|
||||
// 13.39 ParseTemporalYearMonthString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalyearmonthstring
|
||||
ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalYearMonthString).
|
||||
auto parse_result = parse_iso8601(Production::TemporalYearMonthString, iso_string);
|
||||
|
@ -1740,7 +1740,7 @@ ThrowCompletionOr<double> to_positive_integer(VM& vm, Value argument)
|
|||
}
|
||||
|
||||
// 13.43 PrepareTemporalFields ( fields, fieldNames, requiredFields ), https://tc39.es/proposal-temporal/#sec-temporal-preparetemporalfields
|
||||
ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields, Vector<String> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields)
|
||||
ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields, Vector<DeprecatedString> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
|
|||
// 4. If requiredFields is partial and any is false, then
|
||||
if (required_fields.has<PrepareTemporalFieldsPartial>() && !any) {
|
||||
// a. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, String::join(", "sv, field_names));
|
||||
return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, DeprecatedString::join(", "sv, field_names));
|
||||
}
|
||||
|
||||
// 5. Return result.
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
|
@ -57,14 +57,14 @@ struct TemporalInstant {
|
|||
u16 millisecond;
|
||||
u16 microsecond;
|
||||
u16 nanosecond;
|
||||
Optional<String> time_zone_offset;
|
||||
Optional<DeprecatedString> time_zone_offset;
|
||||
};
|
||||
|
||||
struct TemporalDate {
|
||||
i32 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
Optional<String> calendar;
|
||||
Optional<DeprecatedString> calendar;
|
||||
};
|
||||
|
||||
struct TemporalTime {
|
||||
|
@ -74,27 +74,27 @@ struct TemporalTime {
|
|||
u16 millisecond;
|
||||
u16 microsecond;
|
||||
u16 nanosecond;
|
||||
Optional<String> calendar = {};
|
||||
Optional<DeprecatedString> calendar = {};
|
||||
};
|
||||
|
||||
struct TemporalTimeZone {
|
||||
bool z;
|
||||
Optional<String> offset_string;
|
||||
Optional<String> name;
|
||||
Optional<DeprecatedString> offset_string;
|
||||
Optional<DeprecatedString> name;
|
||||
};
|
||||
|
||||
struct TemporalYearMonth {
|
||||
i32 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
Optional<String> calendar = {};
|
||||
Optional<DeprecatedString> calendar = {};
|
||||
};
|
||||
|
||||
struct TemporalMonthDay {
|
||||
Optional<i32> year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
Optional<String> calendar = {};
|
||||
Optional<DeprecatedString> calendar = {};
|
||||
};
|
||||
|
||||
struct ISODateTime {
|
||||
|
@ -108,19 +108,19 @@ struct ISODateTime {
|
|||
u16 microsecond;
|
||||
u16 nanosecond;
|
||||
TemporalTimeZone time_zone { .z = false, .offset_string = {}, .name = {} };
|
||||
Optional<String> calendar = {};
|
||||
Optional<DeprecatedString> calendar = {};
|
||||
};
|
||||
|
||||
struct SecondsStringPrecision {
|
||||
Variant<StringView, u8> precision;
|
||||
String unit;
|
||||
DeprecatedString unit;
|
||||
u32 increment;
|
||||
};
|
||||
|
||||
struct DifferenceSettings {
|
||||
String smallest_unit;
|
||||
String largest_unit;
|
||||
String rounding_mode;
|
||||
DeprecatedString smallest_unit;
|
||||
DeprecatedString largest_unit;
|
||||
DeprecatedString rounding_mode;
|
||||
u64 rounding_increment;
|
||||
Object& options;
|
||||
};
|
||||
|
@ -135,24 +135,24 @@ using TemporalUnitDefault = Variant<TemporalUnitRequired, Optional<StringView>>;
|
|||
ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(VM&, Value items, Vector<OptionType> const& element_types);
|
||||
ThrowCompletionOr<Object*> get_options_object(VM&, Value options);
|
||||
ThrowCompletionOr<Value> get_option(VM&, Object const& options, PropertyKey const& property, OptionType type, Span<StringView const> values, OptionDefault const&);
|
||||
ThrowCompletionOr<String> to_temporal_overflow(VM&, Object const* options);
|
||||
ThrowCompletionOr<String> to_temporal_disambiguation(VM&, Object const* options);
|
||||
ThrowCompletionOr<String> to_temporal_rounding_mode(VM&, Object const& normalized_options, String const& fallback);
|
||||
StringView negate_temporal_rounding_mode(String const& rounding_mode);
|
||||
ThrowCompletionOr<String> to_temporal_offset(VM&, Object const* options, String const& fallback);
|
||||
ThrowCompletionOr<String> to_calendar_name_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<String> to_time_zone_name_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<String> to_show_offset_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_overflow(VM&, Object const* options);
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_disambiguation(VM&, Object const* options);
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_rounding_mode(VM&, Object const& normalized_options, DeprecatedString const& fallback);
|
||||
StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode);
|
||||
ThrowCompletionOr<DeprecatedString> to_temporal_offset(VM&, Object const* options, DeprecatedString const& fallback);
|
||||
ThrowCompletionOr<DeprecatedString> to_calendar_name_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<DeprecatedString> to_time_zone_name_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<DeprecatedString> to_show_offset_option(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<u64> to_temporal_rounding_increment(VM&, Object const& normalized_options, Optional<double> dividend, bool inclusive);
|
||||
ThrowCompletionOr<u64> to_temporal_date_time_rounding_increment(VM&, Object const& normalized_options, StringView smallest_unit);
|
||||
ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(VM&, Object const& normalized_options);
|
||||
ThrowCompletionOr<Optional<String>> get_temporal_unit(VM&, Object const& normalized_options, PropertyKey const&, UnitGroup, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values = {});
|
||||
ThrowCompletionOr<Optional<DeprecatedString>> get_temporal_unit(VM&, Object const& normalized_options, PropertyKey const&, UnitGroup, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values = {});
|
||||
ThrowCompletionOr<Value> to_relative_temporal_object(VM&, Object const& options);
|
||||
StringView larger_of_two_temporal_units(StringView, StringView);
|
||||
ThrowCompletionOr<Object*> merge_largest_unit_option(VM&, Object const& options, String largest_unit);
|
||||
ThrowCompletionOr<Object*> merge_largest_unit_option(VM&, Object const& options, DeprecatedString largest_unit);
|
||||
Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit);
|
||||
ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(VM&, Object&);
|
||||
String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
||||
DeprecatedString format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
||||
double sign(double);
|
||||
double sign(Crypto::SignedBigInteger const&);
|
||||
UnsignedRoundingMode get_unsigned_rounding_mode(StringView rounding_mode, bool is_negative);
|
||||
|
@ -163,19 +163,19 @@ Crypto::SignedBigInteger round_number_to_increment(Crypto::SignedBigInteger cons
|
|||
Crypto::SignedBigInteger round_number_to_increment_as_if_positive(Crypto::SignedBigInteger const&, u64 increment, StringView rounding_mode);
|
||||
ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM&, StringView iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM&, ParseResult const& parse_result);
|
||||
ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<String> parse_temporal_calendar_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<DeprecatedString> parse_temporal_calendar_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM&, DeprecatedString const& iso_string);
|
||||
ThrowCompletionOr<double> to_positive_integer(VM&, Value argument);
|
||||
ThrowCompletionOr<Object*> prepare_temporal_fields(VM&, Object const& fields, Vector<String> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields);
|
||||
ThrowCompletionOr<Object*> prepare_temporal_fields(VM&, Object const& fields, Vector<DeprecatedString> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields);
|
||||
ThrowCompletionOr<DifferenceSettings> get_difference_settings(VM&, DifferenceOperation, Value options_value, UnitGroup unit_group, Vector<StringView> const& disallowed_units, TemporalUnitDefault const& fallback_smallest_unit, StringView smallest_largest_default_unit);
|
||||
|
||||
template<size_t Size>
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
namespace JS::Temporal {
|
||||
|
||||
// 12 Temporal.Calendar Objects, https://tc39.es/proposal-temporal/#sec-temporal-calendar-objects
|
||||
Calendar::Calendar(String identifier, Object& prototype)
|
||||
Calendar::Calendar(DeprecatedString identifier, Object& prototype)
|
||||
: Object(prototype)
|
||||
, m_identifier(move(identifier))
|
||||
{
|
||||
}
|
||||
|
||||
// 12.1.1 IsBuiltinCalendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal-isbuiltincalendar
|
||||
bool is_builtin_calendar(String const& identifier)
|
||||
bool is_builtin_calendar(DeprecatedString const& identifier)
|
||||
{
|
||||
// 1. Let calendars be AvailableCalendars().
|
||||
auto calendars = available_calendars();
|
||||
|
@ -65,7 +65,7 @@ Span<StringView const> available_calendars()
|
|||
}
|
||||
|
||||
// 12.2.1 CreateTemporalCalendar ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalcalendar
|
||||
ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& identifier, FunctionObject const* new_target)
|
||||
ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, DeprecatedString const& identifier, FunctionObject const* new_target)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -85,7 +85,7 @@ ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& iden
|
|||
}
|
||||
|
||||
// 12.2.2 GetBuiltinCalendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal-getbuiltincalendar
|
||||
ThrowCompletionOr<Calendar*> get_builtin_calendar(VM& vm, String const& identifier)
|
||||
ThrowCompletionOr<Calendar*> get_builtin_calendar(VM& vm, DeprecatedString const& identifier)
|
||||
{
|
||||
// 1. If IsBuiltinCalendar(id) is false, throw a RangeError exception.
|
||||
if (!is_builtin_calendar(identifier))
|
||||
|
@ -103,7 +103,7 @@ Calendar* get_iso8601_calendar(VM& vm)
|
|||
}
|
||||
|
||||
// 12.2.4 CalendarFields ( calendar, fieldNames ), https://tc39.es/proposal-temporal/#sec-temporal-calendarfields
|
||||
ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vector<StringView> const& field_names)
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> calendar_fields(VM& vm, Object& calendar, Vector<StringView> const& field_names)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -112,7 +112,7 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect
|
|||
|
||||
// 2. If fields is undefined, return fieldNames.
|
||||
if (!fields) {
|
||||
Vector<String> result;
|
||||
Vector<DeprecatedString> result;
|
||||
for (auto& value : field_names)
|
||||
result.append(value);
|
||||
return result;
|
||||
|
@ -124,7 +124,7 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect
|
|||
// 4. Return ? IterableToListOfType(fieldsArray, « String »).
|
||||
auto list = TRY(iterable_to_list_of_type(vm, fields_array, { OptionType::String }));
|
||||
|
||||
Vector<String> result;
|
||||
Vector<DeprecatedString> result;
|
||||
for (auto& value : list)
|
||||
result.append(value.as_string().string());
|
||||
return result;
|
||||
|
@ -232,7 +232,7 @@ ThrowCompletionOr<double> calendar_month(VM& vm, Object& calendar, Object& date_
|
|||
}
|
||||
|
||||
// 12.2.10 CalendarMonthCode ( calendar, dateLike ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmonthcode
|
||||
ThrowCompletionOr<String> calendar_month_code(VM& vm, Object& calendar, Object& date_like)
|
||||
ThrowCompletionOr<DeprecatedString> calendar_month_code(VM& vm, Object& calendar, Object& date_like)
|
||||
{
|
||||
// 1. Assert: Type(calendar) is Object.
|
||||
|
||||
|
@ -573,11 +573,11 @@ ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(VM& vm, Object&
|
|||
}
|
||||
|
||||
// 12.2.26 MaybeFormatCalendarAnnotation ( calendarObject, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-maybeformatcalendarannotation
|
||||
ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Object const* calendar_object, StringView show_calendar)
|
||||
ThrowCompletionOr<DeprecatedString> maybe_format_calendar_annotation(VM& vm, Object const* calendar_object, StringView show_calendar)
|
||||
{
|
||||
// 1. If showCalendar is "never", return the empty String.
|
||||
if (show_calendar == "never"sv)
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 2. Assert: Type(calendarObject) is Object.
|
||||
VERIFY(calendar_object);
|
||||
|
@ -590,23 +590,23 @@ ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Object const*
|
|||
}
|
||||
|
||||
// 12.2.27 FormatCalendarAnnotation ( id, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-formatcalendarannotation
|
||||
String format_calendar_annotation(StringView id, StringView show_calendar)
|
||||
DeprecatedString format_calendar_annotation(StringView id, StringView show_calendar)
|
||||
{
|
||||
VERIFY(show_calendar == "auto"sv || show_calendar == "always"sv || show_calendar == "never"sv || show_calendar == "critical"sv);
|
||||
|
||||
// 1. If showCalendar is "never", return the empty String.
|
||||
if (show_calendar == "never"sv)
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 2. If showCalendar is "auto" and id is "iso8601", return the empty String.
|
||||
if (show_calendar == "auto"sv && id == "iso8601"sv)
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 3. If showCalendar is "critical", let flag be "!"; else, let flag be the empty String.
|
||||
auto flag = show_calendar == "critical"sv ? "!"sv : ""sv;
|
||||
|
||||
// 4. Return the string-concatenation of "[", flag, "u-ca=", id, and "]".
|
||||
return String::formatted("[{}u-ca={}]", flag, id);
|
||||
return DeprecatedString::formatted("[{}u-ca={}]", flag, id);
|
||||
}
|
||||
|
||||
// 12.2.28 CalendarEquals ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal-calendarequals
|
||||
|
@ -758,11 +758,11 @@ u8 to_iso_week_of_year(i32 year, u8 month, u8 day)
|
|||
}
|
||||
|
||||
// 12.2.32 ISOMonthCode ( month ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthcode
|
||||
String iso_month_code(u8 month)
|
||||
DeprecatedString iso_month_code(u8 month)
|
||||
{
|
||||
// 1. Let numberPart be ToZeroPaddedDecimalString(month, 2).
|
||||
// 2. Return the string-concatenation of "M" and numberPart.
|
||||
return String::formatted("M{:02}", month);
|
||||
return DeprecatedString::formatted("M{:02}", month);
|
||||
}
|
||||
|
||||
// 12.2.33 ResolveISOMonth ( fields ), https://tc39.es/proposal-temporal/#sec-temporal-resolveisomonth
|
||||
|
|
|
@ -22,27 +22,27 @@ class Calendar final : public Object {
|
|||
public:
|
||||
virtual ~Calendar() override = default;
|
||||
|
||||
[[nodiscard]] String const& identifier() const { return m_identifier; }
|
||||
[[nodiscard]] DeprecatedString const& identifier() const { return m_identifier; }
|
||||
|
||||
private:
|
||||
Calendar(String identifier, Object& prototype);
|
||||
Calendar(DeprecatedString identifier, Object& prototype);
|
||||
|
||||
// 12.5 Properties of Temporal.Calendar Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-calendar-instances
|
||||
String m_identifier; // [[Identifier]]
|
||||
DeprecatedString m_identifier; // [[Identifier]]
|
||||
};
|
||||
|
||||
bool is_builtin_calendar(String const& identifier);
|
||||
bool is_builtin_calendar(DeprecatedString const& identifier);
|
||||
Span<StringView const> available_calendars();
|
||||
ThrowCompletionOr<Calendar*> create_temporal_calendar(VM&, String const& identifier, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<Calendar*> get_builtin_calendar(VM&, String const& identifier);
|
||||
ThrowCompletionOr<Calendar*> create_temporal_calendar(VM&, DeprecatedString const& identifier, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<Calendar*> get_builtin_calendar(VM&, DeprecatedString const& identifier);
|
||||
Calendar* get_iso8601_calendar(VM&);
|
||||
ThrowCompletionOr<Vector<String>> calendar_fields(VM&, Object& calendar, Vector<StringView> const& field_names);
|
||||
ThrowCompletionOr<Vector<DeprecatedString>> calendar_fields(VM&, Object& calendar, Vector<StringView> const& field_names);
|
||||
ThrowCompletionOr<Object*> calendar_merge_fields(VM&, Object& calendar, Object& fields, Object& additional_fields);
|
||||
ThrowCompletionOr<PlainDate*> calendar_date_add(VM&, Object& calendar, Value date, Duration&, Object* options = nullptr, FunctionObject* date_add = nullptr);
|
||||
ThrowCompletionOr<Duration*> calendar_date_until(VM&, Object& calendar, Value one, Value two, Object& options, FunctionObject* date_until = nullptr);
|
||||
ThrowCompletionOr<double> calendar_year(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<double> calendar_month(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<String> calendar_month_code(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<DeprecatedString> calendar_month_code(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<double> calendar_day(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<Value> calendar_day_of_week(VM&, Object& calendar, Object& date_like);
|
||||
ThrowCompletionOr<Value> calendar_day_of_year(VM&, Object& calendar, Object& date_like);
|
||||
|
@ -60,13 +60,13 @@ ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(VM&, Object&);
|
|||
ThrowCompletionOr<PlainDate*> calendar_date_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||
ThrowCompletionOr<PlainYearMonth*> calendar_year_month_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||
ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||
ThrowCompletionOr<String> maybe_format_calendar_annotation(VM&, Object const* calendar_object, StringView show_calendar);
|
||||
String format_calendar_annotation(StringView id, StringView show_calendar);
|
||||
ThrowCompletionOr<DeprecatedString> maybe_format_calendar_annotation(VM&, Object const* calendar_object, StringView show_calendar);
|
||||
DeprecatedString format_calendar_annotation(StringView id, StringView show_calendar);
|
||||
ThrowCompletionOr<bool> calendar_equals(VM&, Object& one, Object& two);
|
||||
ThrowCompletionOr<Object*> consolidate_calendars(VM&, Object& one, Object& two);
|
||||
u8 iso_days_in_month(i32 year, u8 month);
|
||||
u8 to_iso_week_of_year(i32 year, u8 month, u8 day);
|
||||
String iso_month_code(u8 month);
|
||||
DeprecatedString iso_month_code(u8 month);
|
||||
ThrowCompletionOr<double> resolve_iso_month(VM&, Object const& fields);
|
||||
ThrowCompletionOr<ISODateRecord> iso_date_from_fields(VM&, Object const& fields, Object const& options);
|
||||
ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(VM&, Object const& fields, Object const& options);
|
||||
|
|
|
@ -481,7 +481,7 @@ Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, d
|
|||
}
|
||||
|
||||
// 7.5.18 BalanceDuration ( days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, largestUnit [ , relativeTo ] ), https://tc39.es/proposal-temporal/#sec-temporal-balanceduration
|
||||
ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, String const& largest_unit, Object* relative_to)
|
||||
ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, DeprecatedString const& largest_unit, Object* relative_to)
|
||||
{
|
||||
// 1. If relativeTo is not present, set relativeTo to undefined.
|
||||
|
||||
|
@ -627,7 +627,7 @@ ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, doub
|
|||
}
|
||||
|
||||
// 7.5.19 UnbalanceDurationRelative ( years, months, weeks, days, largestUnit, relativeTo ), https://tc39.es/proposal-temporal/#sec-temporal-unbalancedurationrelative
|
||||
ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to)
|
||||
ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -816,7 +816,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double
|
|||
}
|
||||
|
||||
// 7.5.20 BalanceDurationRelative ( years, months, weeks, days, largestUnit, relativeTo ), https://tc39.es/proposal-temporal/#sec-temporal-balancedurationrelative
|
||||
ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to_value)
|
||||
ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to_value)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM& vm, double ye
|
|||
}
|
||||
|
||||
// 7.5.27 TemporalDurationToString ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldurationtostring
|
||||
String temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision)
|
||||
DeprecatedString temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision)
|
||||
{
|
||||
if (precision.has<StringView>())
|
||||
VERIFY(precision.get<StringView>() == "auto"sv);
|
||||
|
@ -1736,7 +1736,7 @@ String temporal_duration_to_string(double years, double months, double weeks, do
|
|||
|
||||
// b. Let decimalPart be ToZeroPaddedDecimalString(fraction, 9).
|
||||
// NOTE: padding with zeros leads to weird results when applied to a double. Not sure if that's a bug in AK/Format.h or if I'm doing this wrong.
|
||||
auto decimal_part = String::formatted("{:09}", (u64)fraction);
|
||||
auto decimal_part = DeprecatedString::formatted("{:09}", (u64)fraction);
|
||||
|
||||
// c. If precision is "auto", then
|
||||
if (precision.has<StringView>() && precision.get<StringView>() == "auto"sv) {
|
||||
|
@ -1748,7 +1748,7 @@ String temporal_duration_to_string(double years, double months, double weeks, do
|
|||
// d. Else if precision = 0, then
|
||||
else if (precision.get<u8>() == 0) {
|
||||
// i. Set decimalPart to "".
|
||||
decimal_part = String::empty();
|
||||
decimal_part = DeprecatedString::empty();
|
||||
}
|
||||
// e. Else,
|
||||
else {
|
||||
|
|
|
@ -132,15 +132,15 @@ ThrowCompletionOr<Duration*> create_temporal_duration(VM&, double years, double
|
|||
Duration* create_negated_temporal_duration(VM&, Duration const& duration);
|
||||
ThrowCompletionOr<double> calculate_offset_shift(VM&, Value relative_to_value, double years, double months, double weeks, double days);
|
||||
Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, double offset_shift);
|
||||
ThrowCompletionOr<TimeDurationRecord> balance_duration(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, String const& largest_unit, Object* relative_to = nullptr);
|
||||
ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to);
|
||||
ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to);
|
||||
ThrowCompletionOr<TimeDurationRecord> balance_duration(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, DeprecatedString const& largest_unit, Object* relative_to = nullptr);
|
||||
ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM&, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to);
|
||||
ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM&, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to);
|
||||
ThrowCompletionOr<DurationRecord> add_duration(VM&, double years1, double months1, double weeks1, double days1, double hours1, double minutes1, double seconds1, double milliseconds1, double microseconds1, double nanoseconds1, double years2, double months2, double weeks2, double days2, double hours2, double minutes2, double seconds2, double milliseconds2, double microseconds2, double nanoseconds2, Value relative_to_value);
|
||||
ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(VM&, Object& calendar, PlainDate& relative_to, Duration& duration, FunctionObject* date_add);
|
||||
ThrowCompletionOr<ZonedDateTime*> move_relative_zoned_date_time(VM&, ZonedDateTime&, double years, double months, double weeks, double days);
|
||||
ThrowCompletionOr<RoundedDuration> round_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object = nullptr);
|
||||
ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object);
|
||||
String temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision);
|
||||
DeprecatedString temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision);
|
||||
ThrowCompletionOr<Duration*> add_duration_to_or_subtract_duration_from_duration(VM&, ArithmeticOperation, Duration const&, Value other_value, Value options_value);
|
||||
|
||||
// 7.5.22 DaysUntil ( earlier, later ), https://tc39.es/proposal-temporal/#sec-temporal-daysuntil
|
||||
|
|
|
@ -110,7 +110,7 @@ ThrowCompletionOr<Instant*> to_temporal_instant(VM& vm, Value item)
|
|||
}
|
||||
|
||||
// 8.5.4 ParseTemporalInstant ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalinstant
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(VM& vm, String const& iso_string)
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(VM& vm, DeprecatedString const& iso_string)
|
||||
{
|
||||
// 1. Assert: Type(isoString) is String.
|
||||
|
||||
|
@ -239,7 +239,7 @@ BigInt* round_temporal_instant(VM& vm, BigInt const& nanoseconds, u64 increment,
|
|||
}
|
||||
|
||||
// 8.5.9 TemporalInstantToString ( instant, timeZone, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporalinstanttostring
|
||||
ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_instant_to_string(VM& vm, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision)
|
||||
{
|
||||
// 1. Assert: Type(instant) is Object.
|
||||
// 2. Assert: instant has an [[InitializedTemporalInstant]] internal slot.
|
||||
|
@ -262,7 +262,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V
|
|||
// 7. Let dateTimeString be ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], undefined, precision, "never").
|
||||
auto date_time_string = TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), nullptr, precision, "never"sv));
|
||||
|
||||
String time_zone_string;
|
||||
DeprecatedString time_zone_string;
|
||||
|
||||
// 8. If timeZone is undefined, then
|
||||
if (time_zone.is_undefined()) {
|
||||
|
@ -279,7 +279,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V
|
|||
}
|
||||
|
||||
// 10. Return the string-concatenation of dateTimeString and timeZoneString.
|
||||
return String::formatted("{}{}", date_time_string, time_zone_string);
|
||||
return DeprecatedString::formatted("{}{}", date_time_string, time_zone_string);
|
||||
}
|
||||
|
||||
// 8.5.10 DifferenceTemporalInstant ( operation, instant, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalinstant
|
||||
|
|
|
@ -45,12 +45,12 @@ bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds);
|
|||
bool is_valid_epoch_nanoseconds(Crypto::SignedBigInteger const& epoch_nanoseconds);
|
||||
ThrowCompletionOr<Instant*> create_temporal_instant(VM&, BigInt const& nanoseconds, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<Instant*> to_temporal_instant(VM&, Value item);
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(VM&, String const& iso_string);
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(VM&, DeprecatedString const& iso_string);
|
||||
i32 compare_epoch_nanoseconds(BigInt const&, BigInt const&);
|
||||
ThrowCompletionOr<BigInt*> add_instant(VM&, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||
BigInt* difference_instant(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, u64 rounding_increment, StringView smallest_unit, StringView rounding_mode);
|
||||
BigInt* round_temporal_instant(VM&, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode);
|
||||
ThrowCompletionOr<String> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
||||
ThrowCompletionOr<Duration*> difference_temporal_instant(VM&, DifferenceOperation, Instant const&, Value other, Value options);
|
||||
ThrowCompletionOr<Instant*> add_duration_to_or_subtract_duration_from_instant(VM&, ArithmeticOperation, Instant const&, Value temporal_duration_like);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ ISODateRecord balance_iso_date(double year, double month, double day)
|
|||
}
|
||||
|
||||
// 3.5.7 PadISOYear ( y ), https://tc39.es/proposal-temporal/#sec-temporal-padisoyear
|
||||
String pad_iso_year(i32 y)
|
||||
DeprecatedString pad_iso_year(i32 y)
|
||||
{
|
||||
// 1. Assert: y is an integer.
|
||||
|
||||
// 2. If y ≥ 0 and y ≤ 9999, then
|
||||
if (y >= 0 && y <= 9999) {
|
||||
// a. Return ToZeroPaddedDecimalString(y, 4).
|
||||
return String::formatted("{:04}", y);
|
||||
return DeprecatedString::formatted("{:04}", y);
|
||||
}
|
||||
|
||||
// 3. If y > 0, let yearSign be "+"; otherwise, let yearSign be "-".
|
||||
|
@ -410,11 +410,11 @@ String pad_iso_year(i32 y)
|
|||
|
||||
// 4. Let year be ToZeroPaddedDecimalString(abs(y), 6).
|
||||
// 5. Return the string-concatenation of yearSign and year.
|
||||
return String::formatted("{}{:06}", year_sign, abs(y));
|
||||
return DeprecatedString::formatted("{}{:06}", year_sign, abs(y));
|
||||
}
|
||||
|
||||
// 3.5.8 TemporalDateToString ( temporalDate, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetostring
|
||||
ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar)
|
||||
{
|
||||
// 1. Assert: Type(temporalDate) is Object.
|
||||
// 2. Assert: temporalDate has an [[InitializedTemporalDate]] internal slot.
|
||||
|
@ -423,16 +423,16 @@ ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_da
|
|||
auto year = pad_iso_year(temporal_date.iso_year());
|
||||
|
||||
// 4. Let month be ToZeroPaddedDecimalString(monthDay.[[ISOMonth]], 2).
|
||||
auto month = String::formatted("{:02}", temporal_date.iso_month());
|
||||
auto month = DeprecatedString::formatted("{:02}", temporal_date.iso_month());
|
||||
|
||||
// 5. Let day be ToZeroPaddedDecimalString(monthDay.[[ISODay]], 2).
|
||||
auto day = String::formatted("{:02}", temporal_date.iso_day());
|
||||
auto day = DeprecatedString::formatted("{:02}", temporal_date.iso_day());
|
||||
|
||||
// 6. Let calendar be ? MaybeFormatCalendarAnnotation(temporalDate.[[Calendar]], showCalendar).
|
||||
auto calendar = TRY(maybe_format_calendar_annotation(vm, &temporal_date.calendar(), show_calendar));
|
||||
|
||||
// 7. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, and calendar.
|
||||
return String::formatted("{}-{}-{}{}", year, month, day, calendar);
|
||||
return DeprecatedString::formatted("{}-{}-{}{}", year, month, day, calendar);
|
||||
}
|
||||
|
||||
// 3.5.9 AddISODate ( year, month, day, years, months, weeks, days, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-addisodate
|
||||
|
|
|
@ -52,8 +52,8 @@ DateDurationRecord difference_iso_date(VM&, i32 year1, u8 month1, u8 day1, i32 y
|
|||
ThrowCompletionOr<ISODateRecord> regulate_iso_date(VM&, double year, double month, double day, StringView overflow);
|
||||
bool is_valid_iso_date(i32 year, u8 month, u8 day);
|
||||
ISODateRecord balance_iso_date(double year, double month, double day);
|
||||
String pad_iso_year(i32 y);
|
||||
ThrowCompletionOr<String> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
||||
DeprecatedString pad_iso_year(i32 y);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar);
|
||||
ThrowCompletionOr<ISODateRecord> add_iso_date(VM&, i32 year, u8 month, u8 day, double years, double months, double weeks, double days, StringView overflow);
|
||||
i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2);
|
||||
ThrowCompletionOr<Duration*> difference_temporal_plain_date(VM&, DifferenceOperation, PlainDate&, Value other, Value options);
|
||||
|
|
|
@ -247,7 +247,7 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM& vm, i32 iso_year
|
|||
}
|
||||
|
||||
// 5.5.6 TemporalDateTimeToString ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, precision, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetimetostring
|
||||
ThrowCompletionOr<String> temporal_date_time_to_string(VM& vm, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_time_to_string(VM& vm, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar)
|
||||
{
|
||||
// 1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
|
||||
|
||||
|
@ -264,7 +264,7 @@ ThrowCompletionOr<String> temporal_date_time_to_string(VM& vm, i32 iso_year, u8
|
|||
auto calendar_string = TRY(maybe_format_calendar_annotation(vm, calendar, show_calendar));
|
||||
|
||||
// 9. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, 0x0054 (LATIN CAPITAL LETTER T), hour, the code unit 0x003A (COLON), minute, seconds, and calendarString.
|
||||
return String::formatted("{}-{:02}-{:02}T{:02}:{:02}{}{}", pad_iso_year(iso_year), iso_month, iso_day, hour, minute, seconds, calendar_string);
|
||||
return DeprecatedString::formatted("{}-{:02}-{:02}T{:02}:{:02}{}{}", pad_iso_year(iso_year), iso_month, iso_day, hour, minute, seconds, calendar_string);
|
||||
}
|
||||
|
||||
// 5.5.7 CompareISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2 ), https://tc39.es/proposal-temporal/#sec-temporal-compareisodatetime
|
||||
|
|
|
@ -69,7 +69,7 @@ ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM&, Object&
|
|||
ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM&, Value item, Object const* options = nullptr);
|
||||
ISODateTime balance_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, i64 nanosecond);
|
||||
ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<String> temporal_date_time_to_string(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_date_time_to_string(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar);
|
||||
i8 compare_iso_date_time(i32 year1, u8 month1, u8 day1, u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, i32 year2, u8 month2, u8 day2, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2);
|
||||
ThrowCompletionOr<TemporalPlainDateTime> add_date_time(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options);
|
||||
ISODateTime round_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length = {});
|
||||
|
|
|
@ -174,7 +174,7 @@ ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(VM& vm, u8 iso_month
|
|||
}
|
||||
|
||||
// 10.5.3 TemporalMonthDayToString ( monthDay, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporalmonthdaytostring
|
||||
ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& month_day, StringView show_calendar)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_month_day_to_string(VM& vm, PlainMonthDay& month_day, StringView show_calendar)
|
||||
{
|
||||
// 1. Assert: Type(monthDay) is Object.
|
||||
// 2. Assert: monthDay has an [[InitializedTemporalMonthDay]] internal slot.
|
||||
|
@ -182,7 +182,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo
|
|||
// 3. Let month be ToZeroPaddedDecimalString(temporalDate.[[ISOMonth]], 2).
|
||||
// 4. Let day be ToZeroPaddedDecimalString(temporalDate.[[ISODay]], 2).
|
||||
// 5. Let result be the string-concatenation of month, the code unit 0x002D (HYPHEN-MINUS), and day.
|
||||
auto result = String::formatted("{:02}-{:02}", month_day.iso_month(), month_day.iso_day());
|
||||
auto result = DeprecatedString::formatted("{:02}-{:02}", month_day.iso_month(), month_day.iso_day());
|
||||
|
||||
// 6. Let calendarID be ? ToString(monthDay.[[Calendar]]).
|
||||
auto calendar_id = TRY(Value(&month_day.calendar()).to_string(vm));
|
||||
|
@ -191,7 +191,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo
|
|||
if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601"sv) {
|
||||
// a. Let year be ! PadISOYear(monthDay.[[ISOYear]]).
|
||||
// b. Set result to the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and result.
|
||||
result = String::formatted("{}-{}", pad_iso_year(month_day.iso_year()), result);
|
||||
result = DeprecatedString::formatted("{}-{}", pad_iso_year(month_day.iso_year()), result);
|
||||
}
|
||||
|
||||
// 8. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar).
|
||||
|
@ -199,7 +199,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo
|
|||
|
||||
// 9. Set result to the string-concatenation of result and calendarString.
|
||||
// 10. Return result.
|
||||
return String::formatted("{}{}", result, calendar_string);
|
||||
return DeprecatedString::formatted("{}{}", result, calendar_string);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ struct ISOMonthDay {
|
|||
|
||||
ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(VM&, Value item, Object const* options = nullptr);
|
||||
ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(VM&, u8 iso_month, u8 iso_day, Object& calendar, i32 reference_iso_year, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<String> temporal_month_day_to_string(VM&, PlainMonthDay&, StringView show_calendar);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_month_day_to_string(VM&, PlainMonthDay&, StringView show_calendar);
|
||||
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ ThrowCompletionOr<TemporalTimeLikeRecord> to_temporal_time_record(VM& vm, Object
|
|||
}
|
||||
|
||||
// 4.5.9 TemporalTimeToString ( hour, minute, second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporaltimetostring
|
||||
String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision)
|
||||
DeprecatedString temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision)
|
||||
{
|
||||
// 1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
|
||||
|
||||
|
@ -445,7 +445,7 @@ String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u
|
|||
auto seconds = format_seconds_string_part(second, millisecond, microsecond, nanosecond, precision);
|
||||
|
||||
// 5. Return the string-concatenation of hour, the code unit 0x003A (COLON), minute, and seconds.
|
||||
return String::formatted("{:02}:{:02}{}", hour, minute, seconds);
|
||||
return DeprecatedString::formatted("{:02}:{:02}{}", hour, minute, seconds);
|
||||
}
|
||||
|
||||
// 4.5.10 CompareTemporalTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 ), https://tc39.es/proposal-temporal/#sec-temporal-comparetemporaltime
|
||||
|
|
|
@ -85,7 +85,7 @@ DaysAndTime balance_time(double hour, double minute, double second, double milli
|
|||
TemporalTime constrain_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond);
|
||||
ThrowCompletionOr<PlainTime*> create_temporal_time(VM&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<TemporalTimeLikeRecord> to_temporal_time_record(VM&, Object const& temporal_time_like, ToTemporalTimeRecordCompleteness = ToTemporalTimeRecordCompleteness::Complete);
|
||||
String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
||||
DeprecatedString temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
||||
i8 compare_temporal_time(u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2);
|
||||
DaysAndTime add_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||
DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {});
|
||||
|
|
|
@ -201,7 +201,7 @@ ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM& vm, i32 iso_ye
|
|||
}
|
||||
|
||||
// 9.5.6 TemporalYearMonthToString ( yearMonth, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporalyearmonthtostring
|
||||
ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar)
|
||||
{
|
||||
// 1. Assert: Type(yearMonth) is Object.
|
||||
// 2. Assert: yearMonth has an [[InitializedTemporalYearMonth]] internal slot.
|
||||
|
@ -209,7 +209,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth&
|
|||
// 3. Let year be ! PadISOYear(yearMonth.[[ISOYear]]).
|
||||
// 4. Let month be ToZeroPaddedDecimalString(yearMonth.[[ISOMonth]], 2).
|
||||
// 5. Let result be the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and month.
|
||||
auto result = String::formatted("{}-{:02}", pad_iso_year(year_month.iso_year()), year_month.iso_month());
|
||||
auto result = DeprecatedString::formatted("{}-{:02}", pad_iso_year(year_month.iso_year()), year_month.iso_month());
|
||||
|
||||
// 6. Let calendarID be ? ToString(yearMonth.[[Calendar]]).
|
||||
auto calendar_id = TRY(Value(&year_month.calendar()).to_string(vm));
|
||||
|
@ -218,7 +218,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth&
|
|||
if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601") {
|
||||
// a. Let day be ToZeroPaddedDecimalString(yearMonth.[[ISODay]], 2).
|
||||
// b. Set result to the string-concatenation of result, the code unit 0x002D (HYPHEN-MINUS), and day.
|
||||
result = String::formatted("{}-{:02}", result, year_month.iso_day());
|
||||
result = DeprecatedString::formatted("{}-{:02}", result, year_month.iso_day());
|
||||
}
|
||||
|
||||
// 8. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar).
|
||||
|
@ -226,7 +226,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth&
|
|||
|
||||
// 9. Set result to the string-concatenation of result and calendarString.
|
||||
// 10. Return result.
|
||||
return String::formatted("{}{}", result, calendar_string);
|
||||
return DeprecatedString::formatted("{}{}", result, calendar_string);
|
||||
}
|
||||
|
||||
// 9.5.7 DifferenceTemporalPlainYearMonth ( operation, yearMonth, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplainyearmonth
|
||||
|
|
|
@ -46,7 +46,7 @@ ThrowCompletionOr<ISOYearMonth> regulate_iso_year_month(VM&, double year, double
|
|||
bool iso_year_month_within_limits(i32 year, u8 month);
|
||||
ISOYearMonth balance_iso_year_month(double year, double month);
|
||||
ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<String> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar);
|
||||
ThrowCompletionOr<DeprecatedString> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar);
|
||||
ThrowCompletionOr<Duration*> difference_temporal_plain_year_month(VM&, DifferenceOperation, PlainYearMonth&, Value other, Value options);
|
||||
ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_plain_year_month(VM&, ArithmeticOperation, PlainYearMonth&, Value temporal_duration_like, Value options_value);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ bool is_available_time_zone_name(StringView time_zone)
|
|||
|
||||
// 11.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-canonicalizetimezonename
|
||||
// 15.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sup-canonicalizetimezonename
|
||||
String canonicalize_time_zone_name(String const& time_zone)
|
||||
DeprecatedString canonicalize_time_zone_name(DeprecatedString const& time_zone)
|
||||
{
|
||||
// 1. Let ianaTimeZone be the String value of the Zone or Link name of the IANA Time Zone Database that is an ASCII-case-insensitive match of timeZone as described in 6.1.
|
||||
// 2. If ianaTimeZone is a Link name, let ianaTimeZone be the String value of the corresponding Zone name as specified in the file backward of the IANA Time Zone Database.
|
||||
|
@ -57,7 +57,7 @@ String canonicalize_time_zone_name(String const& time_zone)
|
|||
}
|
||||
|
||||
// 11.6.1 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM& vm, String const& identifier, FunctionObject const* new_target)
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM& vm, DeprecatedString const& identifier, FunctionObject const* new_target)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -166,7 +166,7 @@ BigInt* get_named_time_zone_previous_transition(VM&, [[maybe_unused]] StringView
|
|||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeZoneNumericUTCOffset
|
||||
static bool parse_time_zone_numeric_utc_offset_syntax(String const& offset_string, StringView& sign, StringView& hours, Optional<StringView>& minutes, Optional<StringView>& seconds, Optional<StringView>& fraction)
|
||||
static bool parse_time_zone_numeric_utc_offset_syntax(DeprecatedString const& offset_string, StringView& sign, StringView& hours, Optional<StringView>& minutes, Optional<StringView>& seconds, Optional<StringView>& fraction)
|
||||
{
|
||||
DateTimeLexer lexer(offset_string);
|
||||
auto sign_part = lexer.consume_sign();
|
||||
|
@ -200,7 +200,7 @@ static bool parse_time_zone_numeric_utc_offset_syntax(String const& offset_strin
|
|||
return !lexer.tell_remaining();
|
||||
}
|
||||
|
||||
bool is_valid_time_zone_numeric_utc_offset_syntax(String const& offset_string)
|
||||
bool is_valid_time_zone_numeric_utc_offset_syntax(DeprecatedString const& offset_string)
|
||||
{
|
||||
StringView discarded;
|
||||
Optional<StringView> optionally_discarded;
|
||||
|
@ -209,7 +209,7 @@ bool is_valid_time_zone_numeric_utc_offset_syntax(String const& offset_string)
|
|||
}
|
||||
|
||||
// 11.6.5 FormatTimeZoneOffsetString ( offsetNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-formattimezoneoffsetstring
|
||||
String format_time_zone_offset_string(double offset_nanoseconds)
|
||||
DeprecatedString format_time_zone_offset_string(double offset_nanoseconds)
|
||||
{
|
||||
auto offset = static_cast<i64>(offset_nanoseconds);
|
||||
|
||||
|
@ -248,7 +248,7 @@ String format_time_zone_offset_string(double offset_nanoseconds)
|
|||
// a. Let fraction be ToZeroPaddedDecimalString(nanoseconds, 9).
|
||||
// b. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
|
||||
// c. Let post be the string-concatenation of the code unit 0x003A (COLON), s, the code unit 0x002E (FULL STOP), and fraction.
|
||||
builder.appendff(":{:02}.{}", seconds, String::formatted("{:09}", nanoseconds).trim("0"sv, TrimMode::Right));
|
||||
builder.appendff(":{:02}.{}", seconds, DeprecatedString::formatted("{:09}", nanoseconds).trim("0"sv, TrimMode::Right));
|
||||
}
|
||||
// 12. Else if seconds ≠ 0, then
|
||||
else if (seconds != 0) {
|
||||
|
@ -263,7 +263,7 @@ String format_time_zone_offset_string(double offset_nanoseconds)
|
|||
}
|
||||
|
||||
// 11.6.6 FormatISOTimeZoneOffsetString ( offsetNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-formatisotimezoneoffsetstring
|
||||
String format_iso_time_zone_offset_string(double offset_nanoseconds)
|
||||
DeprecatedString format_iso_time_zone_offset_string(double offset_nanoseconds)
|
||||
{
|
||||
// 1. Assert: offsetNanoseconds is an integer.
|
||||
VERIFY(trunc(offset_nanoseconds) == offset_nanoseconds);
|
||||
|
@ -286,7 +286,7 @@ String format_iso_time_zone_offset_string(double offset_nanoseconds)
|
|||
// 7. Let h be ToZeroPaddedDecimalString(hours, 2).
|
||||
// 8. Let m be ToZeroPaddedDecimalString(minutes, 2).
|
||||
// 9. Return the string-concatenation of sign, h, the code unit 0x003A (COLON), and m.
|
||||
return String::formatted("{}{:02}:{:02}", sign, (u32)hours, (u32)minutes);
|
||||
return DeprecatedString::formatted("{}{:02}:{:02}", sign, (u32)hours, (u32)minutes);
|
||||
}
|
||||
|
||||
// 11.6.7 ToTemporalTimeZone ( temporalTimeZoneLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimezone
|
||||
|
@ -393,7 +393,7 @@ 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
|
||||
ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant)
|
||||
ThrowCompletionOr<DeprecatedString> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant)
|
||||
{
|
||||
// 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
|
||||
auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(vm, time_zone, instant));
|
||||
|
|
|
@ -22,37 +22,37 @@ public:
|
|||
|
||||
virtual ~TimeZone() override = default;
|
||||
|
||||
[[nodiscard]] String const& identifier() const { return m_identifier; }
|
||||
[[nodiscard]] DeprecatedString const& identifier() const { return m_identifier; }
|
||||
[[nodiscard]] Optional<OffsetType> const& offset_nanoseconds() const { return m_offset_nanoseconds; }
|
||||
|
||||
void set_identifier(String identifier) { m_identifier = move(identifier); };
|
||||
void set_identifier(DeprecatedString identifier) { m_identifier = move(identifier); };
|
||||
void set_offset_nanoseconds(OffsetType offset_nanoseconds) { m_offset_nanoseconds = offset_nanoseconds; };
|
||||
|
||||
private:
|
||||
explicit TimeZone(Object& prototype);
|
||||
|
||||
// 11.5 Properties of Temporal.TimeZone Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-timezone-instances
|
||||
String m_identifier; // [[Identifier]]
|
||||
DeprecatedString m_identifier; // [[Identifier]]
|
||||
Optional<OffsetType> m_offset_nanoseconds; // [[OffsetNanoseconds]]
|
||||
};
|
||||
|
||||
bool is_available_time_zone_name(StringView time_zone);
|
||||
String canonicalize_time_zone_name(String const& time_zone);
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM&, String const& identifier, FunctionObject const* new_target = nullptr);
|
||||
DeprecatedString canonicalize_time_zone_name(DeprecatedString const& time_zone);
|
||||
ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM&, DeprecatedString const& identifier, FunctionObject const* new_target = nullptr);
|
||||
ISODateTime get_iso_parts_from_epoch(VM&, Crypto::SignedBigInteger const& epoch_nanoseconds);
|
||||
BigInt* get_named_time_zone_next_transition(VM&, StringView time_zone_identifier, BigInt const& epoch_nanoseconds);
|
||||
BigInt* get_named_time_zone_previous_transition(VM&, StringView time_zone_identifier, BigInt const& epoch_nanoseconds);
|
||||
String format_time_zone_offset_string(double offset_nanoseconds);
|
||||
String format_iso_time_zone_offset_string(double offset_nanoseconds);
|
||||
DeprecatedString format_time_zone_offset_string(double offset_nanoseconds);
|
||||
DeprecatedString format_iso_time_zone_offset_string(double offset_nanoseconds);
|
||||
ThrowCompletionOr<Object*> to_temporal_time_zone(VM&, Value temporal_time_zone_like);
|
||||
ThrowCompletionOr<double> get_offset_nanoseconds_for(VM&, Value time_zone, Instant&);
|
||||
ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM&, Value time_zone, Instant&);
|
||||
ThrowCompletionOr<DeprecatedString> 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<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<MarkedVector<Instant*>> get_possible_instants_for(VM&, Value time_zone, PlainDateTime&);
|
||||
ThrowCompletionOr<bool> time_zone_equals(VM&, Object& one, Object& two);
|
||||
|
||||
bool is_valid_time_zone_numeric_utc_offset_syntax(String const&);
|
||||
bool is_valid_time_zone_numeric_utc_offset_syntax(DeprecatedString const&);
|
||||
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
|
||||
Object* calendar = nullptr;
|
||||
Object* time_zone = nullptr;
|
||||
Optional<String> offset_string;
|
||||
Optional<DeprecatedString> offset_string;
|
||||
ISODateTime result;
|
||||
|
||||
// 5. If Type(item) is Object, then
|
||||
|
@ -284,7 +284,7 @@ ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(VM& vm, BigInt
|
|||
}
|
||||
|
||||
// 6.5.4 TemporalZonedDateTimeToString ( zonedDateTime, precision, showCalendar, showTimeZone, showOffset [ , increment, unit, roundingMode ] ), https://tc39.es/proposal-temporal/#sec-temporal-temporalzoneddatetimetostring
|
||||
ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment, Optional<StringView> unit, Optional<StringView> rounding_mode)
|
||||
ThrowCompletionOr<DeprecatedString> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment, Optional<StringView> unit, Optional<StringView> rounding_mode)
|
||||
{
|
||||
// 1. If increment is not present, set increment to 1.
|
||||
if (!increment.has_value())
|
||||
|
@ -316,12 +316,12 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi
|
|||
// 9. Let dateTimeString be ? TemporalDateTimeToString(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], isoCalendar, precision, "never").
|
||||
auto date_time_string = TRY(temporal_date_time_to_string(vm, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), temporal_date_time->iso_hour(), temporal_date_time->iso_minute(), temporal_date_time->iso_second(), temporal_date_time->iso_millisecond(), temporal_date_time->iso_microsecond(), temporal_date_time->iso_nanosecond(), iso_calendar, precision, "never"sv));
|
||||
|
||||
String offset_string;
|
||||
DeprecatedString offset_string;
|
||||
|
||||
// 10. If showOffset is "never", then
|
||||
if (show_offset == "never"sv) {
|
||||
// a. Let offsetString be the empty String.
|
||||
offset_string = String::empty();
|
||||
offset_string = DeprecatedString::empty();
|
||||
}
|
||||
// 11. Else,
|
||||
else {
|
||||
|
@ -332,12 +332,12 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi
|
|||
offset_string = format_iso_time_zone_offset_string(offset_ns);
|
||||
}
|
||||
|
||||
String time_zone_string;
|
||||
DeprecatedString time_zone_string;
|
||||
|
||||
// 12. If showTimeZone is "never", then
|
||||
if (show_time_zone == "never"sv) {
|
||||
// a. Let timeZoneString be the empty String.
|
||||
time_zone_string = String::empty();
|
||||
time_zone_string = DeprecatedString::empty();
|
||||
}
|
||||
// 13. Else,
|
||||
else {
|
||||
|
@ -348,14 +348,14 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi
|
|||
auto flag = show_time_zone == "critical"sv ? "!"sv : ""sv;
|
||||
|
||||
// c. Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), flag, timeZoneID, and the code unit 0x005D (RIGHT SQUARE BRACKET).
|
||||
time_zone_string = String::formatted("[{}{}]", flag, time_zone_id);
|
||||
time_zone_string = DeprecatedString::formatted("[{}{}]", flag, time_zone_id);
|
||||
}
|
||||
|
||||
// 14. Let calendarString be ? MaybeFormatCalendarAnnotation(zonedDateTime.[[Calendar]], showCalendar).
|
||||
auto calendar_string = TRY(maybe_format_calendar_annotation(vm, &zoned_date_time.calendar(), show_calendar));
|
||||
|
||||
// 15. Return the string-concatenation of dateTimeString, offsetString, timeZoneString, and calendarString.
|
||||
return String::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string);
|
||||
return DeprecatedString::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string);
|
||||
}
|
||||
|
||||
// 6.5.5 AddZonedDateTime ( epochNanoseconds, timeZone, calendar, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-addzoneddatetime
|
||||
|
|
|
@ -55,7 +55,7 @@ enum class MatchBehavior {
|
|||
ThrowCompletionOr<BigInt const*> interpret_iso_date_time_offset(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, OffsetBehavior offset_behavior, double offset_nanoseconds, Value time_zone, StringView disambiguation, StringView offset_option, MatchBehavior match_behavior);
|
||||
ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM&, Value item, Object const* options = nullptr);
|
||||
ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment = {}, Optional<StringView> unit = {}, Optional<StringView> rounding_mode = {});
|
||||
ThrowCompletionOr<DeprecatedString> temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment = {}, Optional<StringView> unit = {}, Optional<StringView> rounding_mode = {});
|
||||
ThrowCompletionOr<BigInt*> add_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Value time_zone, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options = nullptr);
|
||||
ThrowCompletionOr<DurationRecord> difference_zoned_date_time(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, Object& time_zone, Object& calendar, StringView largest_unit, Object const& options);
|
||||
ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM&, Crypto::SignedBigInteger nanoseconds, Value relative_to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue