Parcourir la source

LibJS: Update AvailableCalendars AO to reflect spec changes

These are editorial and normative changes in the Temporal spec.

See:
- https://github.com/tc39/proposal-temporal/commit/2c977fc
- https://github.com/tc39/proposal-temporal/commit/3af75ec
- https://github.com/tc39/proposal-temporal/commit/75ea812
- https://github.com/tc39/proposal-temporal/commit/e7be49b
- https://github.com/tc39/proposal-temporal/commit/883e00a
- https://github.com/tc39/proposal-temporal/commit/5b9d76a
Linus Groh il y a 3 ans
Parent
commit
e68173b656
1 fichiers modifiés avec 10 ajouts et 5 suppressions
  1. 10 5
      Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

+ 10 - 5
Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

@@ -46,13 +46,18 @@ bool is_builtin_calendar(String const& identifier)
 }
 
 // 12.1.2 AvailableCalendars ( ), https://tc39.es/proposal-temporal/#sec-temporal-availablecalendars
-// NOTE: This is the minimum AvailableCalendars implementation for engines without ECMA-402.
-// NOTE: This can be removed in favor of using `Unicode::get_available_calendars()` once everything is updated to handle non-iso8601 calendars.
 Span<StringView const> available_calendars()
 {
-    // 1. Return « "iso8601" ».
-    static constexpr AK::Array values { "iso8601"sv };
-    return values.span();
+    // 1. Let calendars be the List of String values representing calendar types supported by the implementation.
+    // NOTE: This can be removed in favor of using `Unicode::get_available_calendars()` once everything is updated to handle non-iso8601 calendars.
+    static constexpr AK::Array calendars { "iso8601"sv };
+
+    // 2. Assert: calendars contains "iso8601".
+    // 3. Assert: calendars does not contain any element that does not identify a calendar type in the Unicode Common Locale Data Repository (CLDR).
+    // 4. Sort calendars in order as if an Array of the same values had been sorted using %Array.prototype.sort% with undefined as comparefn.
+
+    // 5. Return calendars.
+    return calendars.span();
 }
 
 // 12.2.1 CreateTemporalCalendar ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalcalendar