mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibJS: Convert PlainTime AOs to ThrowCompletionOr
This commit is contained in:
parent
c57a78423d
commit
229a5ce149
9 changed files with 69 additions and 99 deletions
|
@ -149,7 +149,7 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_time_iso)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Return ! CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
|
// 3. Return ! CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond());
|
return TRY_OR_DISCARD(create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.3.1 SystemTimeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone
|
// 2.3.1 SystemTimeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone
|
||||||
|
|
|
@ -440,9 +440,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_date_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Set temporalTime to ? ToTemporalTime(temporalTime).
|
// 4. Set temporalTime to ? ToTemporalTime(temporalTime).
|
||||||
auto* temporal_time = to_temporal_time(global_object, vm.argument(0));
|
auto* temporal_time = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0)));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 5. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
|
// 5. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
|
||||||
return create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar());
|
return create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar());
|
||||||
|
|
|
@ -104,9 +104,7 @@ Optional<ISODateTime> interpret_temporal_date_time_fields(GlobalObject& global_o
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
// 1. Let timeResult be ? ToTemporalTimeRecord(fields).
|
// 1. Let timeResult be ? ToTemporalTimeRecord(fields).
|
||||||
auto unregulated_time_result = to_temporal_time_record(global_object, fields);
|
auto unregulated_time_result = TRY_OR_DISCARD(to_temporal_time_record(global_object, fields));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 2. Let temporalDate be ? DateFromFields(calendar, fields, options).
|
// 2. Let temporalDate be ? DateFromFields(calendar, fields, options).
|
||||||
auto* temporal_date = date_from_fields(global_object, calendar, fields, options);
|
auto* temporal_date = date_from_fields(global_object, calendar, fields, options);
|
||||||
|
@ -119,21 +117,19 @@ Optional<ISODateTime> interpret_temporal_date_time_fields(GlobalObject& global_o
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
|
// 4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
|
||||||
auto time_result = regulate_time(global_object, unregulated_time_result->hour, unregulated_time_result->minute, unregulated_time_result->second, unregulated_time_result->millisecond, unregulated_time_result->microsecond, unregulated_time_result->nanosecond, *overflow);
|
auto time_result = TRY_OR_DISCARD(regulate_time(global_object, unregulated_time_result.hour, unregulated_time_result.minute, unregulated_time_result.second, unregulated_time_result.millisecond, unregulated_time_result.microsecond, unregulated_time_result.nanosecond, *overflow));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 5. Return the Record { [[Year]]: temporalDate.[[ISOYear]], [[Month]]: temporalDate.[[ISOMonth]], [[Day]]: temporalDate.[[ISODay]], [[Hour]]: timeResult.[[Hour]], [[Minute]]: timeResult.[[Minute]], [[Second]]: timeResult.[[Second]], [[Millisecond]]: timeResult.[[Millisecond]], [[Microsecond]]: timeResult.[[Microsecond]], [[Nanosecond]]: timeResult.[[Nanosecond]] }.
|
// 5. Return the Record { [[Year]]: temporalDate.[[ISOYear]], [[Month]]: temporalDate.[[ISOMonth]], [[Day]]: temporalDate.[[ISODay]], [[Hour]]: timeResult.[[Hour]], [[Minute]]: timeResult.[[Minute]], [[Second]]: timeResult.[[Second]], [[Millisecond]]: timeResult.[[Millisecond]], [[Microsecond]]: timeResult.[[Microsecond]], [[Nanosecond]]: timeResult.[[Nanosecond]] }.
|
||||||
return ISODateTime {
|
return ISODateTime {
|
||||||
.year = temporal_date->iso_year(),
|
.year = temporal_date->iso_year(),
|
||||||
.month = temporal_date->iso_month(),
|
.month = temporal_date->iso_month(),
|
||||||
.day = temporal_date->iso_day(),
|
.day = temporal_date->iso_day(),
|
||||||
.hour = time_result->hour,
|
.hour = time_result.hour,
|
||||||
.minute = time_result->minute,
|
.minute = time_result.minute,
|
||||||
.second = time_result->second,
|
.second = time_result.second,
|
||||||
.millisecond = time_result->millisecond,
|
.millisecond = time_result.millisecond,
|
||||||
.microsecond = time_result->microsecond,
|
.microsecond = time_result.microsecond,
|
||||||
.nanosecond = time_result->nanosecond,
|
.nanosecond = time_result.nanosecond,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,9 +396,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Let plainTime be ? ToTemporalTime(plainTimeLike).
|
// 4. Let plainTime be ? ToTemporalTime(plainTimeLike).
|
||||||
auto* plain_time = to_temporal_time(global_object, vm.argument(0));
|
auto* plain_time = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0)));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 5. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], plainTime.[[ISOHour]], plainTime.[[ISOMinute]], plainTime.[[ISOSecond]], plainTime.[[ISOMillisecond]], plainTime.[[ISOMicrosecond]], plainTime.[[ISONanosecond]], dateTime.[[Calendar]]).
|
// 5. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], plainTime.[[ISOHour]], plainTime.[[ISOMinute]], plainTime.[[ISOSecond]], plainTime.[[ISOMillisecond]], plainTime.[[ISOMicrosecond]], plainTime.[[ISONanosecond]], dateTime.[[Calendar]]).
|
||||||
return create_temporal_date_time(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), plain_time->iso_hour(), plain_time->iso_minute(), plain_time->iso_second(), plain_time->iso_millisecond(), plain_time->iso_microsecond(), plain_time->iso_nanosecond(), date_time->calendar());
|
return create_temporal_date_time(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), plain_time->iso_hour(), plain_time->iso_minute(), plain_time->iso_second(), plain_time->iso_millisecond(), plain_time->iso_microsecond(), plain_time->iso_nanosecond(), date_time->calendar());
|
||||||
|
@ -553,7 +551,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_time)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Return ? CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
|
// 3. Return ? CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond());
|
return TRY_OR_DISCARD(create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.3.41 Temporal.PlainDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.getisofields
|
// 5.3.41 Temporal.PlainDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.getisofields
|
||||||
|
|
|
@ -39,7 +39,7 @@ void PlainTime::visit_edges(Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.2 ToTemporalTime ( item [ , overflow ] ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltime
|
// 4.5.2 ToTemporalTime ( item [ , overflow ] ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltime
|
||||||
PlainTime* to_temporal_time(GlobalObject& global_object, Value item, Optional<StringView> overflow)
|
ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Value item, Optional<StringView> overflow)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -68,54 +68,49 @@ PlainTime* to_temporal_time(GlobalObject& global_object, Value item, Optional<St
|
||||||
// i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
// i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds());
|
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds());
|
||||||
// ii. Set plainDateTime to ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
|
// ii. Set plainDateTime to ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
|
||||||
auto* plain_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &zoned_date_time.time_zone(), *instant, zoned_date_time.calendar()));
|
auto* plain_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &zoned_date_time.time_zone(), *instant, zoned_date_time.calendar()));
|
||||||
// iii. Return ! CreateTemporalTime(plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]]).
|
// iii. Return ! CreateTemporalTime(plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, plain_date_time->iso_hour(), plain_date_time->iso_minute(), plain_date_time->iso_second(), plain_date_time->iso_millisecond(), plain_date_time->iso_microsecond(), plain_date_time->iso_nanosecond());
|
return TRY(create_temporal_time(global_object, plain_date_time->iso_hour(), plain_date_time->iso_minute(), plain_date_time->iso_second(), plain_date_time->iso_millisecond(), plain_date_time->iso_microsecond(), plain_date_time->iso_nanosecond()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// c. If item has an [[InitializedTemporalDateTime]] internal slot, then
|
// c. If item has an [[InitializedTemporalDateTime]] internal slot, then
|
||||||
if (is<PlainDateTime>(item_object)) {
|
if (is<PlainDateTime>(item_object)) {
|
||||||
auto& plain_date_time = static_cast<PlainDateTime&>(item_object);
|
auto& plain_date_time = static_cast<PlainDateTime&>(item_object);
|
||||||
// i. Return ! CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
|
// i. Return ! CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, plain_date_time.iso_hour(), plain_date_time.iso_minute(), plain_date_time.iso_second(), plain_date_time.iso_millisecond(), plain_date_time.iso_microsecond(), plain_date_time.iso_nanosecond());
|
return TRY(create_temporal_time(global_object, plain_date_time.iso_hour(), plain_date_time.iso_minute(), plain_date_time.iso_second(), plain_date_time.iso_millisecond(), plain_date_time.iso_microsecond(), plain_date_time.iso_nanosecond()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// d. Let calendar be ? GetTemporalCalendarWithISODefault(item).
|
// d. Let calendar be ? GetTemporalCalendarWithISODefault(item).
|
||||||
auto* calendar = get_temporal_calendar_with_iso_default(global_object, item_object);
|
auto* calendar = get_temporal_calendar_with_iso_default(global_object, item_object);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// e. If ? ToString(calendar) is not "iso8601", then
|
// e. If ? ToString(calendar) is not "iso8601", then
|
||||||
auto calendar_identifier = Value(calendar).to_string(global_object);
|
auto calendar_identifier = Value(calendar).to_string(global_object);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
if (calendar_identifier != "iso8601"sv) {
|
if (calendar_identifier != "iso8601"sv) {
|
||||||
// i. Throw a RangeError exception.
|
// i. Throw a RangeError exception.
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier);
|
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier);
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// f. Let result be ? ToTemporalTimeRecord(item).
|
// f. Let result be ? ToTemporalTimeRecord(item).
|
||||||
auto unregulated_result = to_temporal_time_record(global_object, item_object);
|
auto unregulated_result = TRY(to_temporal_time_record(global_object, item_object));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// g. Set result to ? RegulateTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
|
// g. Set result to ? RegulateTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
|
||||||
result = regulate_time(global_object, unregulated_result->hour, unregulated_result->minute, unregulated_result->second, unregulated_result->millisecond, unregulated_result->microsecond, unregulated_result->nanosecond, *overflow);
|
result = TRY(regulate_time(global_object, unregulated_result.hour, unregulated_result.minute, unregulated_result.second, unregulated_result.millisecond, unregulated_result.microsecond, unregulated_result.nanosecond, *overflow));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
// 4. Else,
|
// 4. Else,
|
||||||
else {
|
else {
|
||||||
// a. Let string be ? ToString(item).
|
// a. Let string be ? ToString(item).
|
||||||
auto string = item.to_string(global_object);
|
auto string = item.to_string(global_object);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// b. Let result be ? ParseTemporalTimeString(string).
|
// b. Let result be ? ParseTemporalTimeString(string).
|
||||||
result = parse_temporal_time_string(global_object, string);
|
result = parse_temporal_time_string(global_object, string);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// c. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
|
// c. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
|
||||||
VERIFY(is_valid_time(result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond));
|
VERIFY(is_valid_time(result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond));
|
||||||
|
@ -123,17 +118,16 @@ PlainTime* to_temporal_time(GlobalObject& global_object, Value item, Optional<St
|
||||||
// d. If result.[[Calendar]] is not one of undefined or "iso8601", then
|
// d. If result.[[Calendar]] is not one of undefined or "iso8601", then
|
||||||
if (result->calendar.has_value() && *result->calendar != "iso8601"sv) {
|
if (result->calendar.has_value() && *result->calendar != "iso8601"sv) {
|
||||||
// i. Throw a RangeError exception.
|
// i. Throw a RangeError exception.
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, *result->calendar);
|
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, *result->calendar);
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
// 5. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
||||||
return create_temporal_time(global_object, result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond);
|
return TRY(create_temporal_time(global_object, result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.3 ToPartialTime ( temporalTimeLike ), https://tc39.es/proposal-temporal/#sec-temporal-topartialtime
|
// 4.5.3 ToPartialTime ( temporalTimeLike ), https://tc39.es/proposal-temporal/#sec-temporal-topartialtime
|
||||||
Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_object, Object& temporal_time_like)
|
ThrowCompletionOr<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_object, Object& temporal_time_like)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -151,8 +145,8 @@ Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_ob
|
||||||
|
|
||||||
// b. Let value be ? Get(temporalTimeLike, property).
|
// b. Let value be ? Get(temporalTimeLike, property).
|
||||||
auto value = temporal_time_like.get(property);
|
auto value = temporal_time_like.get(property);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// c. If value is not undefined, then
|
// c. If value is not undefined, then
|
||||||
if (!value.is_undefined()) {
|
if (!value.is_undefined()) {
|
||||||
|
@ -161,8 +155,8 @@ Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_ob
|
||||||
|
|
||||||
// ii. Set value to ? ToIntegerThrowOnInfinity(value).
|
// ii. Set value to ? ToIntegerThrowOnInfinity(value).
|
||||||
auto value_number = to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite);
|
auto value_number = to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// iii. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
// iii. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
||||||
result.*internal_slot = value_number;
|
result.*internal_slot = value_number;
|
||||||
|
@ -172,8 +166,7 @@ Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_ob
|
||||||
// 5. If any is false, then
|
// 5. If any is false, then
|
||||||
if (!any) {
|
if (!any) {
|
||||||
// a. Throw a TypeError exception.
|
// a. Throw a TypeError exception.
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::TemporalInvalidPlainTimeLikeObject);
|
return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalInvalidPlainTimeLikeObject);
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Return result.
|
// 6. Return result.
|
||||||
|
@ -181,7 +174,7 @@ Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject& global_ob
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.4 RegulateTime ( hour, minute, second, millisecond, microsecond, nanosecond, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulatetime
|
// 4.5.4 RegulateTime ( hour, minute, second, millisecond, microsecond, nanosecond, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulatetime
|
||||||
Optional<TemporalTime> regulate_time(GlobalObject& global_object, double hour, double minute, double second, double millisecond, double microsecond, double nanosecond, StringView overflow)
|
ThrowCompletionOr<TemporalTime> regulate_time(GlobalObject& global_object, double hour, double minute, double second, double millisecond, double microsecond, double nanosecond, StringView overflow)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -201,10 +194,8 @@ Optional<TemporalTime> regulate_time(GlobalObject& global_object, double hour, d
|
||||||
// 4. If overflow is "reject", then
|
// 4. If overflow is "reject", then
|
||||||
if (overflow == "reject"sv) {
|
if (overflow == "reject"sv) {
|
||||||
// a. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
|
// a. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
|
||||||
if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) {
|
if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond))
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime);
|
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime);
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// b. Return the Record { [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.
|
// b. Return the Record { [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.
|
||||||
return TemporalTime { .hour = static_cast<u8>(hour), .minute = static_cast<u8>(minute), .second = static_cast<u8>(second), .millisecond = static_cast<u16>(millisecond), .microsecond = static_cast<u16>(microsecond), .nanosecond = static_cast<u16>(nanosecond) };
|
return TemporalTime { .hour = static_cast<u8>(hour), .minute = static_cast<u8>(minute), .second = static_cast<u8>(second), .millisecond = static_cast<u16>(millisecond), .microsecond = static_cast<u16>(microsecond), .nanosecond = static_cast<u16>(nanosecond) };
|
||||||
|
@ -339,17 +330,15 @@ TemporalTime constrain_time(double hour, double minute, double second, double mi
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.8 CreateTemporalTime ( hour, minute, second, millisecond, microsecond, nanosecond [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltime
|
// 4.5.8 CreateTemporalTime ( hour, minute, second, millisecond, microsecond, nanosecond [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltime
|
||||||
PlainTime* create_temporal_time(GlobalObject& global_object, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target)
|
ThrowCompletionOr<PlainTime*> create_temporal_time(GlobalObject& global_object, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
// 1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
|
// 1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
|
||||||
|
|
||||||
// 2. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
|
// 2. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
|
||||||
if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) {
|
if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond))
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime);
|
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime);
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. If newTarget is not present, set it to %Temporal.PlainTime%.
|
// 3. If newTarget is not present, set it to %Temporal.PlainTime%.
|
||||||
if (!new_target)
|
if (!new_target)
|
||||||
|
@ -363,14 +352,14 @@ PlainTime* create_temporal_time(GlobalObject& global_object, u8 hour, u8 minute,
|
||||||
// 9. Set object.[[ISOMicrosecond]] to microsecond.
|
// 9. Set object.[[ISOMicrosecond]] to microsecond.
|
||||||
// 10. Set object.[[ISONanosecond]] to nanosecond.
|
// 10. Set object.[[ISONanosecond]] to nanosecond.
|
||||||
// 11. Set object.[[Calendar]] to ! GetISO8601Calendar().
|
// 11. Set object.[[Calendar]] to ! GetISO8601Calendar().
|
||||||
auto* object = TRY_OR_DISCARD(ordinary_create_from_constructor<PlainTime>(global_object, *new_target, &GlobalObject::temporal_plain_time_prototype, hour, minute, second, millisecond, microsecond, nanosecond, *get_iso8601_calendar(global_object)));
|
auto* object = TRY(ordinary_create_from_constructor<PlainTime>(global_object, *new_target, &GlobalObject::temporal_plain_time_prototype, hour, minute, second, millisecond, microsecond, nanosecond, *get_iso8601_calendar(global_object)));
|
||||||
|
|
||||||
// 12. Return object.
|
// 12. Return object.
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5.9 ToTemporalTimeRecord ( temporalTimeLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimerecord
|
// 4.5.9 ToTemporalTimeRecord ( temporalTimeLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimerecord
|
||||||
Optional<UnregulatedTemporalTime> to_temporal_time_record(GlobalObject& global_object, Object const& temporal_time_like)
|
ThrowCompletionOr<UnregulatedTemporalTime> to_temporal_time_record(GlobalObject& global_object, Object const& temporal_time_like)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -385,20 +374,19 @@ Optional<UnregulatedTemporalTime> to_temporal_time_record(GlobalObject& global_o
|
||||||
|
|
||||||
// b. Let value be ? Get(temporalTimeLike, property).
|
// b. Let value be ? Get(temporalTimeLike, property).
|
||||||
auto value = temporal_time_like.get(property);
|
auto value = temporal_time_like.get(property);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// c. If value is undefined, then
|
// c. If value is undefined, then
|
||||||
if (value.is_undefined()) {
|
if (value.is_undefined()) {
|
||||||
// i. Throw a TypeError exception.
|
// i. Throw a TypeError exception.
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::TemporalMissingRequiredProperty, property);
|
return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingRequiredProperty, property);
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// d. Set value to ? ToIntegerThrowOnInfinity(value).
|
// d. Set value to ? ToIntegerThrowOnInfinity(value).
|
||||||
auto value_number = to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite);
|
auto value_number = to_integer_throw_on_infinity(global_object, value, ErrorType::TemporalPropertyMustBeFinite);
|
||||||
if (vm.exception())
|
if (auto* exception = vm.exception())
|
||||||
return {};
|
return throw_completion(exception->value());
|
||||||
|
|
||||||
// e. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
// e. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
||||||
result.*internal_slot = value_number;
|
result.*internal_slot = value_number;
|
||||||
|
|
|
@ -90,14 +90,14 @@ auto temporal_time_like_properties = [](VM& vm) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
PlainTime* to_temporal_time(GlobalObject&, Value item, Optional<StringView> overflow = {});
|
ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject&, Value item, Optional<StringView> overflow = {});
|
||||||
Optional<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject&, Object& temporal_time_like);
|
ThrowCompletionOr<PartialUnregulatedTemporalTime> to_partial_time(GlobalObject&, Object& temporal_time_like);
|
||||||
Optional<TemporalTime> regulate_time(GlobalObject&, double hour, double minute, double second, double millisecond, double microsecond, double nanosecond, StringView overflow);
|
ThrowCompletionOr<TemporalTime> regulate_time(GlobalObject&, double hour, double minute, double second, double millisecond, double microsecond, double nanosecond, StringView overflow);
|
||||||
bool is_valid_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond);
|
bool is_valid_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond);
|
||||||
DaysAndTime balance_time(i64 hour, i64 minute, i64 second, i64 millisecond, i64 microsecond, i64 nanosecond);
|
DaysAndTime balance_time(i64 hour, i64 minute, i64 second, i64 millisecond, i64 microsecond, i64 nanosecond);
|
||||||
TemporalTime constrain_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond);
|
TemporalTime constrain_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond);
|
||||||
PlainTime* create_temporal_time(GlobalObject&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target = nullptr);
|
ThrowCompletionOr<PlainTime*> create_temporal_time(GlobalObject&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target = nullptr);
|
||||||
Optional<UnregulatedTemporalTime> to_temporal_time_record(GlobalObject&, Object const& temporal_time_like);
|
ThrowCompletionOr<UnregulatedTemporalTime> to_temporal_time_record(GlobalObject&, Object const& temporal_time_like);
|
||||||
String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision);
|
String 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);
|
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 round_time(GlobalObject&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {});
|
DaysAndTime round_time(GlobalObject&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {});
|
||||||
|
|
|
@ -90,7 +90,7 @@ Value PlainTimeConstructor::construct(FunctionObject& new_target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).
|
// 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).
|
||||||
return create_temporal_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, &new_target);
|
return TRY_OR_DISCARD(create_temporal_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, &new_target));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from
|
// 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from
|
||||||
|
@ -112,25 +112,21 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimeConstructor::from)
|
||||||
if (item.is_object() && is<PlainTime>(item.as_object())) {
|
if (item.is_object() && is<PlainTime>(item.as_object())) {
|
||||||
auto& plain_time = static_cast<PlainTime&>(item.as_object());
|
auto& plain_time = static_cast<PlainTime&>(item.as_object());
|
||||||
// a. Return ? CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
|
// a. Return ? CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, plain_time.iso_hour(), plain_time.iso_minute(), plain_time.iso_second(), plain_time.iso_millisecond(), plain_time.iso_microsecond(), plain_time.iso_nanosecond());
|
return TRY_OR_DISCARD(create_temporal_time(global_object, plain_time.iso_hour(), plain_time.iso_minute(), plain_time.iso_second(), plain_time.iso_millisecond(), plain_time.iso_microsecond(), plain_time.iso_nanosecond()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Return ? ToTemporalTime(item, overflow).
|
// 4. Return ? ToTemporalTime(item, overflow).
|
||||||
return to_temporal_time(global_object, item, *overflow);
|
return TRY_OR_DISCARD(to_temporal_time(global_object, item, *overflow));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.2.3 Temporal.PlainTime.compare ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.compare
|
// 4.2.3 Temporal.PlainTime.compare ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.compare
|
||||||
JS_DEFINE_NATIVE_FUNCTION(PlainTimeConstructor::compare)
|
JS_DEFINE_NATIVE_FUNCTION(PlainTimeConstructor::compare)
|
||||||
{
|
{
|
||||||
// 1. Set one to ? ToTemporalTime(one).
|
// 1. Set one to ? ToTemporalTime(one).
|
||||||
auto* one = to_temporal_time(global_object, vm.argument(0));
|
auto* one = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0)));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 2. Set two to ? ToTemporalTime(two).
|
// 2. Set two to ? ToTemporalTime(two).
|
||||||
auto* two = to_temporal_time(global_object, vm.argument(1));
|
auto* two = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(1)));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 3. Return 𝔽(! CompareTemporalTime(one.[[ISOHour]], one.[[ISOMinute]], one.[[ISOSecond]], one.[[ISOMillisecond]], one.[[ISOMicrosecond]], one.[[ISONanosecond]], two.[[ISOHour]], two.[[ISOMinute]], two.[[ISOSecond]], two.[[ISOMillisecond]], two.[[ISOMicrosecond]], two.[[ISONanosecond]])).
|
// 3. Return 𝔽(! CompareTemporalTime(one.[[ISOHour]], one.[[ISOMinute]], one.[[ISOSecond]], one.[[ISOMillisecond]], one.[[ISOMicrosecond]], one.[[ISONanosecond]], two.[[ISOHour]], two.[[ISOMinute]], two.[[ISOSecond]], two.[[ISOMillisecond]], two.[[ISOMicrosecond]], two.[[ISONanosecond]])).
|
||||||
return Value(compare_temporal_time(one->iso_hour(), one->iso_minute(), one->iso_second(), one->iso_millisecond(), one->iso_microsecond(), one->iso_nanosecond(), two->iso_hour(), two->iso_minute(), two->iso_second(), two->iso_millisecond(), two->iso_microsecond(), two->iso_nanosecond()));
|
return Value(compare_temporal_time(one->iso_hour(), one->iso_minute(), one->iso_second(), one->iso_millisecond(), one->iso_microsecond(), one->iso_nanosecond(), two->iso_hour(), two->iso_minute(), two->iso_second(), two->iso_millisecond(), two->iso_microsecond(), two->iso_nanosecond()));
|
||||||
|
|
|
@ -189,9 +189,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. Let partialTime be ? ToPartialTime(temporalTimeLike).
|
// 9. Let partialTime be ? ToPartialTime(temporalTimeLike).
|
||||||
auto partial_time = to_partial_time(global_object, temporal_time_like);
|
auto partial_time = TRY_OR_DISCARD(to_partial_time(global_object, temporal_time_like));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 10. Set options to ? GetOptionsObject(options).
|
// 10. Set options to ? GetOptionsObject(options).
|
||||||
auto* options = get_options_object(global_object, vm.argument(1));
|
auto* options = get_options_object(global_object, vm.argument(1));
|
||||||
|
@ -207,45 +205,43 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
||||||
// a. Let hour be partialTime.[[Hour]].
|
// a. Let hour be partialTime.[[Hour]].
|
||||||
// 13. Else,
|
// 13. Else,
|
||||||
// a. Let hour be temporalTime.[[ISOHour]].
|
// a. Let hour be temporalTime.[[ISOHour]].
|
||||||
auto hour = partial_time->hour.value_or(temporal_time->iso_hour());
|
auto hour = partial_time.hour.value_or(temporal_time->iso_hour());
|
||||||
|
|
||||||
// 14. If partialTime.[[Minute]] is not undefined, then
|
// 14. If partialTime.[[Minute]] is not undefined, then
|
||||||
// a. Let minute be partialTime.[[Minute]].
|
// a. Let minute be partialTime.[[Minute]].
|
||||||
// 15. Else,
|
// 15. Else,
|
||||||
// a. Let minute be temporalTime.[[ISOMinute]].
|
// a. Let minute be temporalTime.[[ISOMinute]].
|
||||||
auto minute = partial_time->minute.value_or(temporal_time->iso_minute());
|
auto minute = partial_time.minute.value_or(temporal_time->iso_minute());
|
||||||
|
|
||||||
// 16. If partialTime.[[Second]] is not undefined, then
|
// 16. If partialTime.[[Second]] is not undefined, then
|
||||||
// a. Let second be partialTime.[[Second]].
|
// a. Let second be partialTime.[[Second]].
|
||||||
// 17. Else,
|
// 17. Else,
|
||||||
// a. Let second be temporalTime.[[ISOSecond]].
|
// a. Let second be temporalTime.[[ISOSecond]].
|
||||||
auto second = partial_time->second.value_or(temporal_time->iso_second());
|
auto second = partial_time.second.value_or(temporal_time->iso_second());
|
||||||
|
|
||||||
// 18. If partialTime.[[Millisecond]] is not undefined, then
|
// 18. If partialTime.[[Millisecond]] is not undefined, then
|
||||||
// a. Let millisecond be partialTime.[[Millisecond]].
|
// a. Let millisecond be partialTime.[[Millisecond]].
|
||||||
// 19. Else,
|
// 19. Else,
|
||||||
// a. Let millisecond be temporalTime.[[ISOMillisecond]].
|
// a. Let millisecond be temporalTime.[[ISOMillisecond]].
|
||||||
auto millisecond = partial_time->millisecond.value_or(temporal_time->iso_millisecond());
|
auto millisecond = partial_time.millisecond.value_or(temporal_time->iso_millisecond());
|
||||||
|
|
||||||
// 20. If partialTime.[[Microsecond]] is not undefined, then
|
// 20. If partialTime.[[Microsecond]] is not undefined, then
|
||||||
// a. Let microsecond be partialTime.[[Microsecond]].
|
// a. Let microsecond be partialTime.[[Microsecond]].
|
||||||
// 21. Else,
|
// 21. Else,
|
||||||
// a. Let microsecond be temporalTime.[[ISOMicrosecond]].
|
// a. Let microsecond be temporalTime.[[ISOMicrosecond]].
|
||||||
auto microsecond = partial_time->microsecond.value_or(temporal_time->iso_microsecond());
|
auto microsecond = partial_time.microsecond.value_or(temporal_time->iso_microsecond());
|
||||||
|
|
||||||
// 22. If partialTime.[[Nanosecond]] is not undefined, then
|
// 22. If partialTime.[[Nanosecond]] is not undefined, then
|
||||||
// a. Let nanosecond be partialTime.[[Nanosecond]].
|
// a. Let nanosecond be partialTime.[[Nanosecond]].
|
||||||
// 23. Else,
|
// 23. Else,
|
||||||
// a. Let nanosecond be temporalTime.[[ISONanosecond]].
|
// a. Let nanosecond be temporalTime.[[ISONanosecond]].
|
||||||
auto nanosecond = partial_time->nanosecond.value_or(temporal_time->iso_nanosecond());
|
auto nanosecond = partial_time.nanosecond.value_or(temporal_time->iso_nanosecond());
|
||||||
|
|
||||||
// 24. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
|
// 24. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
|
||||||
auto result = regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, *overflow);
|
auto result = TRY_OR_DISCARD(regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, *overflow));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 25. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
// 25. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
||||||
return create_temporal_time(global_object, result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond);
|
return TRY_OR_DISCARD(create_temporal_time(global_object, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.3.16 Temporal.PlainTime.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.equals
|
// 4.3.16 Temporal.PlainTime.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.equals
|
||||||
|
@ -258,9 +254,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::equals)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// 3. Set other to ? ToTemporalTime(other).
|
// 3. Set other to ? ToTemporalTime(other).
|
||||||
auto* other = to_temporal_time(global_object, vm.argument(0));
|
auto* other = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0)));
|
||||||
if (vm.exception())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false.
|
// 4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false.
|
||||||
if (temporal_time->iso_hour() != other->iso_hour())
|
if (temporal_time->iso_hour() != other->iso_hour())
|
||||||
|
|
|
@ -773,7 +773,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time)
|
||||||
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
|
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
|
||||||
|
|
||||||
// 7. Return ? CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]).
|
// 7. Return ? CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]).
|
||||||
return create_temporal_time(global_object, 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());
|
return TRY_OR_DISCARD(create_temporal_time(global_object, 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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.3.49 Temporal.ZonedDateTime.prototype.toPlainDateTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindatetime
|
// 6.3.49 Temporal.ZonedDateTime.prototype.toPlainDateTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindatetime
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue