diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 518f6351c2..c273997c7a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -165,7 +165,7 @@ ThrowCompletionOr to_temporal_duration_record(VM& vm, Value temp auto duration_record_fields = temporal_duration_record_fields(vm); auto partial_duration_record_fields = temporal_duration_record_fields>(vm); - // 5. For each row of Table 8, except the header row, in table order, do + // 5. For each row of Table 8, except the header row, do for (size_t i = 0; i < duration_record_fields.size(); ++i) { // a. Let fieldName be the Field Name value of the current row. auto field_name = duration_record_fields[i].field_name; @@ -292,7 +292,14 @@ ThrowCompletionOr to_temporal_partial_duration_record(VM& // 3. Let any be false. auto any = false; - // 4. For each row of Table 7, except the header row, in table order, do + // 4. Let propertyNames be a new empty List. + + // 5. For each row of Table 7, except the header row, do + // a. Append the property name in the Property Name column of the row to propertyNames. + // 6. Let sortedPropertyNames be SortStringListByCodeUnit(propertyNames). + // 7. For each property name property of sortedPropertyNames, do + + // 8. For each row of Table 7, except the header row, in table order, do for (auto& [field_name, property] : temporal_duration_record_fields>(vm)) { // a. Let property be the Property Name value of the current row. @@ -307,19 +314,19 @@ ThrowCompletionOr to_temporal_partial_duration_record(VM& // ii. Set value to ? ToIntegerWithoutRounding(value). auto value_integer = TRY(to_integer_without_rounding(vm, value, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, property.as_string(), value.to_string_without_side_effects())); - // iii. Let fieldName be the Field Name value of the current row. + // iii. Let fieldName be the field name named in the Field Name column in Table 7 for Property Name property. // iv. Set the field of result whose name is fieldName to value. result.*field_name = value_integer; } } - // 5. If any is false, then + // 9. If any is false, then if (!any) { // a. Throw a TypeError exception. return vm.throw_completion(ErrorType::TemporalInvalidDurationLikeObject); } - // 6. Return result. + // 10. Return result. return result; } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp index d2f91c3406..a4200f5688 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp @@ -347,7 +347,7 @@ ThrowCompletionOr to_temporal_time_record(VM& vm, Object // 3. Let result be a new TemporalTimeLike Record with each field set to undefined. auto result = TemporalTimeLikeRecord {}; - // 4. For each row of Table 4, except the header row, in table order, do + // 4. For each row of Table 4, except the header row, do for (auto& [field, property_name] : temporal_time_like_record_fields>(vm)) { // a. Let field be the Field Name value of the current row. // b. Let propertyName be the Property Name value of the current row. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h index 6cae990c34..9889b6d2b5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h @@ -77,11 +77,11 @@ auto temporal_time_like_record_fields = [](VM& vm) { using FieldT = TemporalTimeLikeRecordField; return AK::Array { FieldT { &StructT::hour, vm.names.hour }, - FieldT { &StructT::microsecond, vm.names.microsecond }, - FieldT { &StructT::millisecond, vm.names.millisecond }, FieldT { &StructT::minute, vm.names.minute }, - FieldT { &StructT::nanosecond, vm.names.nanosecond }, FieldT { &StructT::second, vm.names.second }, + FieldT { &StructT::millisecond, vm.names.millisecond }, + FieldT { &StructT::microsecond, vm.names.microsecond }, + FieldT { &StructT::nanosecond, vm.names.nanosecond }, }; };