forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: For some reason, Apple will return a timezone via the default timezone and then report that it is not in its list of `knownTimeZoneNames`. However, it can still be passed to the constructor of `NSTimeZone`, so for all intents and purposes it should be considered a valid time zone. Therefore, we manually add the TZ. However, because there is a chance that the default TZ can change while the program is running, we must keep track of a list of all valid timezones. This begins as just the knownTimeZoneNames. It is then potentially appended to every time the default time zone is requested, with the value of the default time zone. Reviewed By: neildhar Differential Revision: D41042493 fbshipit-source-id: ec72e7692acd7a0f823f70e7f9070d8d5a4c2768
- Loading branch information
1 parent
2fbd6ac
commit 1fe1ccb
Showing
2 changed files
with
62 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
|
||
// RUN: TZ=US/Pacific %hermes -O -target=HBC %s | %FileCheck --match-full-lines %s | ||
// REQUIRES: intl | ||
|
||
print("test default timezone"); | ||
// CHECK-LABEL: test default timezone | ||
|
||
const timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
const options = { | ||
year: 'numeric', month: 'numeric', day: 'numeric', | ||
hour: 'numeric', minute: 'numeric', second: 'numeric', | ||
hour12: false, | ||
timeZone: timeZone | ||
}; | ||
const date = new Date(Date.UTC(2020, 0, 2, 3, 45, 00, 30)); | ||
print(new Intl.DateTimeFormat('en-US', options).format(date)); | ||
// CHECK-NEXT: 1/1/2020, 19:45:00 |