facebook / facebook/hermes

Intl.DateTimeFormat() returns short timeZoneName with GMT offset removed in some locales

Open
#1,601 4 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## Bug Description

`Intl.DateTimeFormat()` returns short timeZoneName with GMT offset removed in some locales.

- [x] I have run `gradle clean` and confirmed this bug does not occur with JSC
- [x] The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable):
React Native version: 0.77.0
OS: iOS 18.2.1
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): running on iPhone, so I guess one of the arm ones

## Steps To Reproduce

```javascript
Intl.DateTimeFormat(
"en-GB",
{ timeZone: "Pacific/Honolulu", timeZoneName: "short" }
)
.formatToParts( new Date( ) )
.find( p => p.type === "timeZoneName" ).value
```
gives the following output

```
GMT
```

## The Expected Behavior

```
GMT-10
```

FWIW, I see the correct output in Android 14, and by "correct" I mean the output I see in Firefox and Chrome, `GMT-10` (I would expect it to be `HST` like it is in `en-US`, but an accurate offset seems preferable to an inaccurate short name).

I am pretty sure this is just due to `formatToParts()` behaving a bit differently. The `-` and `10` are in subsequent parts as `literal` and `year` elements. That's just not how the method behaves in a browser.

Related: https://github.com/marnusw/date-fns-tz/issues/306

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.