-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: master
Are you sure you want to change the base?
Conversation
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" |
There was a problem hiding this comment.
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 😄
-
Could you change the code to use
AssertEqual
instead of just printing it like below line?
accounting/formatnumber_test.go
Line 12 in 17a4ce5
AssertEqual(t, FormatNumber(123456789.213123, 3, ",", "."), "123,456,789.213") -
And I think you can move this test into the formatnumber_test.go file because this code actually tests the formatnumber function.
-
I think you don't need to copy & paste the Locale struct into the test file. I think testing
FormatNumber
directly with"₹"
parameter is enough because it isunit 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 { |
There was a problem hiding this comment.
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? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go fmt
does that.
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 |
No description provided.