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

indian format bug fixed #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mjafaari
Copy link

@mjafaari mjafaari commented Feb 4, 2021

No description provided.

@leekchan
Copy link
Owner

Thank you very much 😄 Looks like this PR will fix the issue #16 .


lc := LocaleInfo["INR"]
ac := accounting.Accounting{Symbol: lc.ComSymbol, Precision: 2, Thousand: lc.ThouSep, Decimal: lc.DecSep}
fmt.Println(ac.FormatMoney(500000)) // "$500,000.00"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some comments for this test 😄

  1. Could you change the code to use AssertEqual instead of just printing it like below line?

    AssertEqual(t, FormatNumber(123456789.213123, 3, ",", "."), "123,456,789.213")

  2. And I think you can move this test into the formatnumber_test.go file because this code actually tests the formatnumber function.

  3. I think you don't need to copy & paste the Locale struct into the test file. I think testingFormatNumber directly with "₹" parameter is enough because it is unit test 😄

@@ -105,8 +139,8 @@ func FormatNumberInt(x int, precision int, thousand string, decimalStr string) s
var minus bool

if x < 0 {
if x * -1 < 0 {
return FormatNumber(x, precision, thousand, decimalStr)
if x*-1 < 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this formatting convention? 😄

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go fmt does that.

@svandecappelle
Copy link

svandecappelle commented Dec 8, 2021

Searching for similar formatting system I found this can solve the problem of number formatting :

p := message.NewPrinter(language.Hindi)
p.Printf("%s %f", "₹", 100000000.0)

playground: https://go.dev/play/p/bJMKuCYM2JZ
Hope this could help :D

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 this pull request may close these issues.

5 participants