diff --git a/lib/Platform/Intl/PlatformIntlApple.mm b/lib/Platform/Intl/PlatformIntlApple.mm index 090bb952350..97b9e8f0b56 100644 --- a/lib/Platform/Intl/PlatformIntlApple.mm +++ b/lib/Platform/Intl/PlatformIntlApple.mm @@ -1462,8 +1462,15 @@ uint8_t getCurrencyDigits(std::u16string_view code) { timeZone = timeZoneIt->second.getString(); // b. If the result of IsValidTimeZoneName(timeZone) is false, then if (!isValidTimeZoneName(timeZone)) { - // i. Throw a RangeError exception. - return runtime.raiseRangeError("Incorrect timeZone information provided"); + if ([[NSTimeZone alloc] initWithName:u16StringToNSString(timeZone)] != + nil) { + validTimeZoneNames().update(timeZone); + } else { + // i. Throw a RangeError exception. + return runtime.raiseRangeError( + vm::TwineChar16("Incorrect timeZone information provided: ") + + vm::TwineChar16(timeZone.c_str())); + } } // c. Let timeZone be CanonicalizeTimeZoneName(timeZone). timeZone = canonicalizeTimeZoneName(timeZone); diff --git a/test/hermes/intl/date-time-format-apple.js b/test/hermes/intl/date-time-format-apple.js index 83e1c28e50b..ac498e35883 100644 --- a/test/hermes/intl/date-time-format-apple.js +++ b/test/hermes/intl/date-time-format-apple.js @@ -39,6 +39,9 @@ print(new Intl.DateTimeFormat('en-US', { timeStyle: 'long', timeZone: 'PST'}).fo print(new Intl.DateTimeFormat('en-US', { timeStyle: 'long', timeZone: 'EET'}).format(date)); // CHECK-NEXT: 5:45:00{{.+}}AM GMT+2 +print(new Intl.DateTimeFormat("en-US", { timeZone: "US/Eastern", timeZoneName: "short" }).resolvedOptions().timeZone); +// CHECK-NEXT: US/Eastern + try { print(new Intl.DateTimeFormat('en-US', { timeStyle: 'long', timeZone: 'XXX'}).format(date)); print("Succeeded");