Przeglądaj źródła

LibJS: Capture TimeFraction parse result instead of Fraction

Not much of a difference as TimeFraction just parses Fraction, but let's
do it correctly. Small mistake I did in 4b7f716.

Thanks to YouTube user gla3dr for noticing this :^)
Linus Groh 3 lat temu
rodzic
commit
f7fe7f8c77

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp

@@ -1086,7 +1086,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(GlobalObject& global_object,
     auto hour_part = parse_result.time_hour;
     auto hour_part = parse_result.time_hour;
     auto minute_part = parse_result.time_minute;
     auto minute_part = parse_result.time_minute;
     auto second_part = parse_result.time_second;
     auto second_part = parse_result.time_second;
-    auto fraction_part = parse_result.fractional_part;
+    auto fraction_part = parse_result.time_fraction;
     auto calendar_part = parse_result.calendar_name;
     auto calendar_part = parse_result.calendar_name;
 
 
     // 3. If the first code unit of year is 0x2212 (MINUS SIGN), replace it with the code unit 0x002D (HYPHEN-MINUS).
     // 3. If the first code unit of year is 0x2212 (MINUS SIGN), replace it with the code unit 0x002D (HYPHEN-MINUS).

+ 6 - 2
Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp

@@ -440,7 +440,6 @@ bool ISO8601Parser::parse_fraction()
         return false;
         return false;
     if (!parse_fractional_part())
     if (!parse_fractional_part())
         return false;
         return false;
-    m_state.parse_result.fractional_part = transaction.parsed_string_view();
     transaction.commit();
     transaction.commit();
     return true;
     return true;
 }
 }
@@ -450,7 +449,12 @@ bool ISO8601Parser::parse_time_fraction()
 {
 {
     // TimeFraction :
     // TimeFraction :
     //     Fraction
     //     Fraction
-    return parse_fraction();
+    StateTransaction transaction { *this };
+    if (!parse_fraction())
+        return false;
+    m_state.parse_result.time_fraction = transaction.parsed_string_view();
+    transaction.commit();
+    return true;
 }
 }
 
 
 // https://tc39.es/proposal-temporal/#prod-TimeZoneUTCOffsetSign
 // https://tc39.es/proposal-temporal/#prod-TimeZoneUTCOffsetSign

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h

@@ -21,7 +21,7 @@ struct ParseResult {
     Optional<StringView> time_hour;
     Optional<StringView> time_hour;
     Optional<StringView> time_minute;
     Optional<StringView> time_minute;
     Optional<StringView> time_second;
     Optional<StringView> time_second;
-    Optional<StringView> fractional_part;
+    Optional<StringView> time_fraction;
     Optional<StringView> calendar_name;
     Optional<StringView> calendar_name;
     Optional<StringView> utc_designator;
     Optional<StringView> utc_designator;
     Optional<StringView> time_zone_utc_offset_sign;
     Optional<StringView> time_zone_utc_offset_sign;