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

Should we include a DurationFormat polyfill? #211

Open
justingrant opened this issue Jan 16, 2023 · 4 comments
Open

Should we include a DurationFormat polyfill? #211

justingrant opened this issue Jan 16, 2023 · 4 comments

Comments

@justingrant
Copy link
Contributor

Should we bundle a polyfill for Intl.DurationFormat so that Duration.p.toLocaleString will work?

There seem to be a few of these polyfills around:

@ptomato
Copy link
Contributor

ptomato commented Jan 16, 2023

I'm in favour of it, but at the time of writing neither of the listed ones seem to be functioning; the formatjs one currently logs TODO instead of the actual formatting part and the other one is an empty package.

@justingrant
Copy link
Contributor Author

Lol, I didn't actually dig in to see if those polyfills did anything. Although the second one does look like there's runtime code in there (see https://github.com/fullcalendar/temporal/blob/main/packages/durationformat-polyfill/src/index.ts), not sure why the package is empty. No idea if it works, though!

@12wrigja
Copy link
Contributor

12wrigja commented Mar 6, 2023

This isn't a direct polyfill, more a ponyfill, but one implementation was contributed to Closure recently for use within Google: https://github.com/google/closure-library/blob/master/closure/goog/i18n/durationformat.js

I'd be worried about the relevant code-size costs to getting this right: the Closure version strongly depends on accessing a bunch of gencode that comes from CLDR to get all the relevant pattern parts and symbols. Within the Closure Compiler ecosystem, this is mostly OK because we can do per-locale compilation and optimize out most of the rest of the symbols, but this isn't feasible in the OSS community to my knowledge.

@jakobfdev
Copy link

jakobfdev commented Mar 12, 2024

#277
Typing is not correct at least in one place because a polyfill for DurationFormat is missing.

the formatjs polyfill has been developed throughout the last year. tests only show english, but german also yields good results.
Maybe reconsider including it - the types would help nonetheless.

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

4 participants