decimal icon indicating copy to clipboard operation
decimal copied to clipboard

NewFromString: Thousands Separator on Input

Open coip opened this issue 5 years ago • 5 comments

the string $8,112.61 breaks for me.

I am hesitant to open this given that the $ is already not supported.

Should FromString variants handle string formatters? Maybe strip out $/, characters?

Hesitant to preemptively submit a PR given i18n implications, ie comma meaning fractional vs purely formatting in European countries.

Open to feedback, and submit PR for s/[$,]//g filtering if that's reasonable and aligned with the project goals.

Thanks!

coip avatar Jun 17 '19 14:06 coip

Also, only found one other related issue, #98, though I believe that issue is for formatting output whereas this is for handling formatted input

coip avatar Jun 17 '19 15:06 coip

Hi @coip. Thanks for suggesting such functionality. Tbh, I'm not convinced of the necessity of handling money formatted string by FromString method. Anyways, I'm aware that decimal libs are mostly used for money operations, so we will consider implementing this. (FYI. @njason)

mwoss avatar Dec 02 '19 23:12 mwoss

I'm not convinced of the necessity

I don’t blame ya. It is a bit out of the scope given the use-case specificity. Maybe considering it more broadly, as a FromFormattedString for example, would help it be more applicable for a ~parsing suite.

we will consider implementing this.

Appreciate it, if I find some bandwidth I will try to open a feasible pr but that’s honestly not v likely at the moment.

coip avatar Dec 03 '19 00:12 coip

NewFromFormattedString would be a better idea, IMO. We will add this task to backlog ;)

mwoss avatar Dec 05 '19 11:12 mwoss