Skip to content

Fix invalid timezone errors for valid timezones on Apple platforms.#1611

Closed
chrsmys wants to merge 1 commit intofacebook:mainfrom
chrsmys:nschris/incorrectTimezoneErrorFix
Closed

Fix invalid timezone errors for valid timezones on Apple platforms.#1611
chrsmys wants to merge 1 commit intofacebook:mainfrom
chrsmys:nschris/incorrectTimezoneErrorFix

Conversation

@chrsmys
Copy link

@chrsmys chrsmys commented Feb 8, 2025

Summary

This addresses issue #1607 where valid timezones were raising invalid time zone errors. The root of the issue is that hermes relies on NSTimeZone.knownTimeZoneNames to determine valid time zones, but this does not provide a complete list of all time zones NSTimeZone supports. US/Eastern is an example of a timezone that is not listed in knownTimeZoneNames but will generate a valid NSTimeZone.

To address this problem this will first attempt to create an NSTimeZone before raising the range exception. If it's a valid time zone then it will get added to the validTimeZoneNames list, otherwise an exception will be raised.

Test Plan

To test this I built Hermes locally on a Mac and ran this gist to detect which timezones do & do not work. I also tested negative cases to ensure exceptions were still raised when an invalid time zone is provided. Here is list of timezones that previously did not work, but now do:

Africa/Asmera
Africa/Timbuktu
America/Argentina/ComodRivadavia
America/Atka
America/Buenos_Aires
America/Catamarca
America/Coral_Harbour
America/Cordoba
America/Ensenada
America/Fort_Wayne
America/Indianapolis
America/Jujuy
America/Knox_IN
America/Louisville
America/Mendoza
America/Porto_Acre
America/Rosario
America/Virgin
Asia/Ashkhabad
Asia/Chungking
Asia/Dacca
Asia/Istanbul
Asia/Kolkata
Asia/Macao
Asia/Saigon
Asia/Tel_Aviv
Asia/Thimbu
Asia/Ujung_Pandang
Asia/Ulan_Bator
Atlantic/Faeroe
Atlantic/Jan_Mayen
Australia/ACT
Australia/Canberra
Australia/LHI
Australia/North
Australia/NSW
Australia/Queensland
Australia/South
Australia/Tasmania
Australia/Victoria
Australia/West
Australia/Yancowinna
Brazil/Acre
Brazil/DeNoronha
Brazil/East
Brazil/West
Canada/Atlantic
Canada/Central
Canada/Eastern
Canada/Mountain
Canada/Newfoundland
Canada/Pacific
Canada/Saskatchewan
Canada/Yukon
Chile/Continental
Chile/EasterIsland
CST6CDT
Cuba
Egypt
Eire
EST5EDT
Etc/GMT
Etc/GMT+0
Etc/GMT+1
Etc/GMT+10
Etc/GMT+11
Etc/GMT+12
Etc/GMT+2
Etc/GMT+3
Etc/GMT+4
Etc/GMT+5
Etc/GMT+6
Etc/GMT+7
Etc/GMT+8
Etc/GMT+9
Etc/GMT-0
Etc/GMT-1
Etc/GMT-10
Etc/GMT-11
Etc/GMT-12
Etc/GMT-13
Etc/GMT-14
Etc/GMT-2
Etc/GMT-3
Etc/GMT-4
Etc/GMT-5
Etc/GMT-6
Etc/GMT-7
Etc/GMT-8
Etc/GMT-9
Etc/GMT0
Etc/Greenwich
Etc/UCT
Etc/Universal
Etc/UTC
Etc/Zulu
Europe/Belfast
Europe/Nicosia
Europe/Tiraspol
Factory
GB
GB-Eire
GMT+0
GMT-0
GMT0
Greenwich
Hongkong
Iceland
Iran
Israel
Jamaica
Japan
Kwajalein
Libya
MET
Mexico/BajaNorte
Mexico/BajaSur
Mexico/General
MST7MDT
Navajo
NZ
NZ-CHAT
Pacific/Samoa
Pacific/Yap
Poland
Portugal
PRC
PST8PDT
ROC
ROK
Singapore
Turkey
UCT
Universal
US/Alaska
US/Aleutian
US/Arizona
US/Central
US/East-Indiana
US/Eastern
US/Hawaii
US/Indiana-Starke
US/Michigan
US/Mountain
US/Pacific
US/Samoa
W-SU
Zulu

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 8, 2025
@chrsmys
Copy link
Author

chrsmys commented Feb 16, 2025

@robhogan Do you know who might be best to take a look at this? Thanks!

@tienle46
Copy link

This PR should fix issue in our application. Please take a look soon.

@chrsmys
Copy link
Author

chrsmys commented Feb 18, 2025

@tmikov sorry for the direct tag, but do you know anyone who can take a look?

@tmikov
Copy link
Contributor

tmikov commented Feb 19, 2025

Will do

@chrsmys chrsmys force-pushed the nschris/incorrectTimezoneErrorFix branch from 222faef to 3ebd46d Compare February 19, 2025 23:48
@chrsmys chrsmys requested a review from lavenzg February 19, 2025 23:58
Copy link
Contributor

@lavenzg lavenzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chrsmys
Copy link
Author

chrsmys commented Feb 21, 2025

Cannot test target “ApplePlatformsIntegrationMobileTests” on “Any iOS Device”: Tests must be run on a concrete device

@lavenzg Looks like it's CI is failing to find a simulator to run on.

@chrsmys
Copy link
Author

chrsmys commented Feb 21, 2025

Looks like it might get fixed by this #1626

@lavenzg
Copy link
Contributor

lavenzg commented Feb 24, 2025

Cannot test target “ApplePlatformsIntegrationMobileTests” on “Any iOS Device”: Tests must be run on a concrete device

@lavenzg Looks like it's CI is failing to find a simulator to run on.

Yeah we are aware of that. Just ignore that for now.

@lavenzg lavenzg force-pushed the nschris/incorrectTimezoneErrorFix branch from 3ebd46d to 05e7e4a Compare February 24, 2025 18:32
@facebook-github-bot
Copy link
Contributor

@lavenzg has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@maxpowa
Copy link

maxpowa commented Feb 28, 2025

Would love to see this fix backported into previous react-native versions of hermes - I had great success applying this patch to the v0.76-stable branch when running on iOS 17/18. Unfortunately, when running on iOS 15/16 the app immediately crashes with a Symbol not found: __ZNSt3__122__libcpp_verbose_abortEPKcz error. I don't think this error is specific to this patch, more just something wrong with my emulation of the react-native hermes framework build process.

@chrsmys
Copy link
Author

chrsmys commented Mar 6, 2025

@lavenzg just wanted to bump this in case it got lost

@facebook-github-bot
Copy link
Contributor

@lavenzg merged this pull request in b8ad3c1.

@lavenzg
Copy link
Contributor

lavenzg commented Mar 11, 2025

@lavenzg just wanted to bump this in case it got lost

It has been merged. Thanks!

facebook-github-bot pushed a commit that referenced this pull request Mar 17, 2025
…1611) (#1611)

Summary:
Original Author: chris@nschris.com
Original Git: b8ad3c1
Original Reviewed By: avp
Original Revision: D70109465

This addresses issue #1607 where valid timezones were raising invalid time zone errors. The root of the issue is that hermes relies on `NSTimeZone.knownTimeZoneNames` to determine valid time zones, but this does not provide a complete list of all time zones NSTimeZone supports. `US/Eastern` is an example of a timezone that is not listed in knownTimeZoneNames but will generate a valid NSTimeZone.

To address this problem this will first attempt to create an NSTimeZone before raising the range exception.  If it's a valid time zone then it will get added to the validTimeZoneNames list, otherwise an exception will be raised.

Pull Request resolved: #1611

Pulled By: lavenzg

Reviewed By: lavenzg

Differential Revision: D71332435

fbshipit-source-id: 3f8c11003d31736c28bab64a3362fc3cf5946379
@navarroaxel
Copy link
Contributor

@lavenzg could we please backport this to rn/0.79-stable? 🙏

@tmikov
Copy link
Contributor

tmikov commented Jun 22, 2025

@lavenzg could we please backport this to rn/0.79-stable? 🙏

Thanks for the request. We don't backport changes to older Hermes releases as a matter of policy. Our team focuses resources on forward development rather than maintaining multiple release branches.

Since Hermes is open source, you're welcome to create the backport yourself and submit a PR, if needed for your use case. Keep in mind that any backported changes would also need to be picked up by the corresponding React Native release branch to be useful.

navarroaxel pushed a commit to Alpha-Priority/hermes that referenced this pull request Jun 22, 2025
…acebook#1611) (facebook#1611)

Summary:
Original Author: chris@nschris.com
Original Git: b8ad3c1
Original Reviewed By: avp
Original Revision: D70109465

This addresses issue facebook#1607 where valid timezones were raising invalid time zone errors. The root of the issue is that hermes relies on `NSTimeZone.knownTimeZoneNames` to determine valid time zones, but this does not provide a complete list of all time zones NSTimeZone supports. `US/Eastern` is an example of a timezone that is not listed in knownTimeZoneNames but will generate a valid NSTimeZone.

To address this problem this will first attempt to create an NSTimeZone before raising the range exception.  If it's a valid time zone then it will get added to the validTimeZoneNames list, otherwise an exception will be raised.

Pull Request resolved: facebook#1611

Pulled By: lavenzg

Reviewed By: lavenzg

Differential Revision: D71332435

fbshipit-source-id: 3f8c11003d31736c28bab64a3362fc3cf5946379
@navarroaxel
Copy link
Contributor

@tmikov Hello, I've created the PR to backport the commit. #1723

navarroaxel pushed a commit to navarroaxel/hermes that referenced this pull request Jun 22, 2025
…acebook#1611) (facebook#1611)

Summary:
Original Author: chris@nschris.com
Original Git: b8ad3c1
Original Reviewed By: avp
Original Revision: D70109465

This addresses issue facebook#1607 where valid timezones were raising invalid time zone errors. The root of the issue is that hermes relies on `NSTimeZone.knownTimeZoneNames` to determine valid time zones, but this does not provide a complete list of all time zones NSTimeZone supports. `US/Eastern` is an example of a timezone that is not listed in knownTimeZoneNames but will generate a valid NSTimeZone.

To address this problem this will first attempt to create an NSTimeZone before raising the range exception.  If it's a valid time zone then it will get added to the validTimeZoneNames list, otherwise an exception will be raised.

Pull Request resolved: facebook#1611

Pulled By: lavenzg

Reviewed By: lavenzg

Differential Revision: D71332435

fbshipit-source-id: 3f8c11003d31736c28bab64a3362fc3cf5946379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants