-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which package?
@formatjs/intl-datetimeformat
Describe the bug
When using the @formatjs/intl-datetimeformat polyfill and loading the locale data for cy (Welsh), the timezone information does not correctly get displayed.
For a user in the Europe/London timezone, dates during the daylight savings period (Mar-Oct) will only show GMT as the timezone. The offset of +1 or BST will not be displayed.
Similarly if the "long"
timeZoneName
is provided it will output Amser Safonol Greenwich
instead of Amser Haf Prydain
(what appears in the CLDR json data for cy).
Looking at the generated locale-data which ships with @formatjs/intl-datetimeformat
, the cy.js
file lists the same content strings for DST times
"Europe/London": {
"long": [
"Amser Safonol Greenwich",
"Amser Safonol Greenwich"
],
"short": [
"GMT",
"GMT"
]
},
Worth noting, the times converted are correct, its just the timezone information which is wrong.
Generally the polyfills have saved me a world of pain in the past and allowed the use of the nicer Intl APIs. Unfortunately now I have some contracts with the teaching branch of the Welsh Government and must ensure they get the correct information.
Any assistance or quick bug-fix would be super appreciated <3
To Reproduce
Codesandbox URL
Reproducible Steps/Repo
Simply load up the Codesandbox URL and view the output.
Alternatively:
- Import datetime polyfill + cy locale-data
import "@formatjs/intl-datetimeformat/polyfill-force";
import "@formatjs/intl-datetimeformat/add-all-tz.js";
import "@formatjs/intl-datetimeformat/locale-data/cy";
- Set default timezone to Europe/London
Intl.DateTimeFormat.__setDefaultTimeZone("Europe/London");
- Display a date in the DST period with timezone information (short or long) in Welsh
new Intl.DateTimeFormat("cy", {
day: "2-digit",
month: "short",
year: "numeric",
hour: "numeric",
minute: "2-digit",
timeZoneName: "short",
}).format(new Date("2025-09-26T12:00:00Z"));
- Output will not have the correct GMT offset or long text.
Expected behavior
Given the language is set to cy, the user in the Europe/London timezone, and a date is in the DST period,
- when using the
"short"
timeZoneName
, either GMT+1 or BST should be output - when using the
"long"
timeZoneName
,Amser Haf Prydain
should be output (as per CLDR data)
It should mimic environments which don't need the polyfill (built-in Intl support for cy)
- Firefox uses GMT+1
- Safari uses GMT+1
- NodeJs uses GMT+1