Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with @formatjs/datetimeformat polyfill #38

Open
Titozzz opened this issue Jan 13, 2025 · 4 comments
Open

Incompatibility with @formatjs/datetimeformat polyfill #38

Titozzz opened this issue Jan 13, 2025 · 4 comments

Comments

@Titozzz
Copy link

Titozzz commented Jan 13, 2025

When polyfilling Intl.DateTimeFormat with @formatjs/datetimeformat and using tzOffset, 2 issues arise:

https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/IsValidTimeZoneName.ts#L6
https://github.com/date-fns/tz/blob/main/src/tzOffset/index.ts#L20

  1. The timezone format isn't supported by the polyfill (that is supposed to cover 100% of the spec),
    -> So who's correct ? Does the format here or there needs fixing ?

  2. The cache that's added to prevent performance issues is not working when the method throws, so it will try to recreate a new format function on every call, harming performance seriously when using a JS engine that is slow regarding Intl APIs (hermes on react native)

Fixing 1) would mean 2) doesn't affect me anymore but we could still address the issue to not retry and crash everytime.

I'm open to addressing those issues in a PR, but just making just we are aligned first, thanks!

Linked issue in the other repo: formatjs/formatjs#4804

@ryaa
Copy link

ryaa commented Feb 18, 2025

@Titozzz as I understand the error happens because timeZoneName: "longOffset" which is not supported on iOS 15.4 or below (see https://github.com/date-fns/tz/blob/main/src/tzOffset/index.ts#L22). More details can be found #23 (comment)

@Titozzz
Copy link
Author

Titozzz commented Feb 18, 2025

Yes iOS 15.4 or below has that issue, but the polyfill is supposed to address that, as it is supposed to fill the gaps to match the spec. Here the issue that I'm pointing at is that even the polyfill doesn't fix the issue, which mean that either the polyfill or this library is wrong

@ryaa
Copy link

ryaa commented Feb 18, 2025

but the polyfill is supposed to address that, as it is supposed to fill the gaps to match the spec

exactly. This is the polyfill issue.

@ryaa
Copy link

ryaa commented Feb 18, 2025

Until formatjs polyfills is fixed to correctly handle the above use case, I implemented a temporary fix for date-fns/tz package - see #23 (comment)

I can create a PR for date-fns/tz based on my temporary fix but I believe that this must be fixed in formatjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants