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

feature request/question: Reversing the formatting of a number? #35

Open
gpampara opened this issue Jun 17, 2021 · 2 comments · May be fixed by #41
Open

feature request/question: Reversing the formatting of a number? #35

gpampara opened this issue Jun 17, 2021 · 2 comments · May be fixed by #41

Comments

@gpampara
Copy link

Thanks for the library, it's used extensively in our app but I wanted to find out if the unformatting of a number has been considered or if it is perhaps out of scope?

Would be great to have a parse-like function to obtain a Float from a formatted number in String representation. We have some internal code currently that is doing this and would gladly contribute it.

@cuducos
Copy link
Owner

cuducos commented Jun 17, 2021

Hum… interesting.

Personally, I must say I have never thought about it — but something like that might make sense (drawing from the README.md example):

import FormatNumber exposing (unparse)
import FormatNumber.Locales exposing (Decimals(..), Locale, usLocale)

sharesLocale : Locale
sharesLocale =
    { usLocale
        | decimals = Exact 3
        , negativePrefix = "("
        , negativeSuffix = ")"
    }


unparse sharesLocale "(3.142)" --> -3.142

Surely we have to be clear in the docs about precision, but that is not a blocker IMHO.

In other news, I am not sure when I can work on that, but I am happy to code review contributions — feel free to draft a PR : )

@praveentiru praveentiru linked a pull request Jul 9, 2021 that will close this issue
@praveentiru
Copy link
Contributor

@cuducos Update on this. I have a first working version of code but, it is ugly. I am re-factoring the same. Will create a PR once it is done.

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

Successfully merging a pull request may close this issue.

3 participants