1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

LibJS+LibTimeZone: Explicitly canonicalize "GMT" to "UTC"

This is a normative change in the ECMA-402 spec. See:
50eb413

Note that this canonicalization already occurred. As the above commit
alludes to, we parse the rearguard format of the TZDB, so GMT is already
an alias to Etc/GMT. But it doesn't hurt to be explicit here.
This commit is contained in:
Timothy Flynn 2023-03-23 08:00:16 -04:00 committed by Linus Groh
parent c5c6065611
commit 6d49eab8a6
Notes: sideshowbarker 2024-07-17 02:57:43 +09:00
2 changed files with 3 additions and 2 deletions

View file

@ -40,6 +40,7 @@ bool is_available_time_zone_name(StringView time_zone)
return ::TimeZone::time_zone_from_string(time_zone).has_value();
}
// 6.4.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/ecma402/#sec-canonicalizetimezonename
// 11.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-canonicalizetimezonename
// 15.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sup-canonicalizetimezonename
ThrowCompletionOr<String> canonicalize_time_zone_name(VM& vm, StringView time_zone)
@ -48,7 +49,7 @@ ThrowCompletionOr<String> canonicalize_time_zone_name(VM& vm, StringView time_zo
// 2. If ianaTimeZone is a Link name, let ianaTimeZone be the String value of the corresponding Zone name as specified in the file backward of the IANA Time Zone Database.
auto iana_time_zone = ::TimeZone::canonicalize_time_zone(time_zone);
// 3. If ianaTimeZone is "Etc/UTC" or "Etc/GMT", return "UTC".
// 3. If ianaTimeZone is one of "Etc/UTC", "Etc/GMT", or "GMT", return "UTC".
// NOTE: This is already done in canonicalize_time_zone().
// 4. Return ianaTimeZone.

View file

@ -177,7 +177,7 @@ Optional<StringView> canonicalize_time_zone(StringView time_zone)
return {};
auto canonical_time_zone = time_zone_to_string(*maybe_time_zone);
if (canonical_time_zone.is_one_of("Etc/UTC"sv, "Etc/GMT"sv))
if (canonical_time_zone.is_one_of("Etc/UTC"sv, "Etc/GMT"sv, "GMT"sv))
return "UTC"sv;
return canonical_time_zone;