summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-10-17 09:08:20 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-17 12:56:05 +0200
commit72997c6b77ed7d6c24e9975a67eafabda9496921 (patch)
tree4d37480f13bd2d1963188c21c5b53f477e1f8b2a /Userland/Libraries
parentfefe447cf567ac95514c7e36d10185610172b023 (diff)
downloadserenity-72997c6b77ed7d6c24e9975a67eafabda9496921.zip
LibJS: Define IsValidTimeZoneName in terms of AvailableTimeZones
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/d83dcf0 Note that even though we already implement AvailableTimeZones for Intl, I kept the existing implementation calling into LibTimeZone directly.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
index addbf37030..4146674ca7 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp
@@ -28,11 +28,11 @@ TimeZone::TimeZone(Object& prototype)
}
// 11.1.1 IsValidTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-isvalidtimezonename
-// 15.1.1 IsValidTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sup-isvalidtimezonename
-bool is_valid_time_zone_name(String const& time_zone)
+bool is_valid_time_zone_name(StringView time_zone)
{
- // 1. If one of the Zone or Link names of the IANA Time Zone Database is an ASCII-case-insensitive match of timeZone as described in 6.1, return true.
- // 2. If timeZone is an ASCII-case-insensitive match of "UTC", return true.
+ // 1. Let timeZones be AvailableTimeZones().
+ // 2. For each String candidate in timeZones, do
+ // a. If timeZone is an ASCII-case-insensitive match for candidate, return true.
// 3. Return false.
// NOTE: When LibTimeZone is built without ENABLE_TIME_ZONE_DATA, this only recognizes 'UTC',
// which matches the minimum requirements of the Temporal spec.
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h
index 235d0db800..36c2efda4a 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h
@@ -36,7 +36,7 @@ private:
Optional<OffsetType> m_offset_nanoseconds; // [[OffsetNanoseconds]]
};
-bool is_valid_time_zone_name(String const& time_zone);
+bool is_valid_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);
ISODateTime get_iso_parts_from_epoch(VM&, Crypto::SignedBigInteger const& epoch_nanoseconds);