elm-format-number icon indicating copy to clipboard operation
elm-format-number copied to clipboard

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

Open gpampara opened this issue 3 years ago • 2 comments

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.

gpampara avatar Jun 17 '21 12:06 gpampara

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 : )

cuducos avatar Jun 17 '21 13:06 cuducos

@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.

praveentiru avatar Jul 17 '21 03:07 praveentiru