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

Percent format and parsing #940

Closed
alc86 opened this issue Apr 11, 2023 · 2 comments
Closed

Percent format and parsing #940

alc86 opened this issue Apr 11, 2023 · 2 comments

Comments

@alc86
Copy link

alc86 commented Apr 11, 2023

Hi,

I have recognised that the formatting and parsing currently work with factor 100. So this means value 1 is formatted to 100% and 100% is parsed to 1. Is there a possibilty to change the factor because we would like to have value 1 as 1% and 1% should be parsed to value 1.

@pau1tuck
Copy link

@alc86, could you elaborate on "currently work with factor 100" please?
Do you mean that the numberFormatter and numberParser are returning incorrect values specifically for 1 and 100%?.numberFormatter({ style: "percent" })( 0.5 ) // > "50%"
.numberParser({ style: "percent" })( "50%" ) // > 0.5

@rxaviers
Copy link
Member

Thank you @pau1tuck for asking for clarification. I think @alc86 wants to be able to pass 1 and get "1%" as output.

@alc86 that can be accomplished by dividing the input before passing it to globalize, like x/100. That said, I don't foresee a need for globalize API to change. Let me know if you need something else or if this blocks any use case I couldn't anticipate here. Thanks

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

3 participants