diff options
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 7 | ||||
-rw-r--r-- | modules/base/tool_test.go | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go index 47ce125853..a981fd6c57 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "github.com/dustin/go-humanize" ) @@ -143,9 +144,9 @@ func FileSize(s int64) string { } // PrettyNumber produces a string form of the given number in base 10 with -// commas after every three orders of magnitud -func PrettyNumber(v int64) string { - return humanize.Comma(v) +// commas after every three orders of magnitude +func PrettyNumber(i interface{}) string { + return humanize.Comma(util.NumberIntoInt64(i)) } // Subtract deals with subtraction of all types of number. diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go index 5280827e8a..6685168bac 100644 --- a/modules/base/tool_test.go +++ b/modules/base/tool_test.go @@ -117,6 +117,7 @@ func TestFileSize(t *testing.T) { func TestPrettyNumber(t *testing.T) { assert.Equal(t, "23,342,432", PrettyNumber(23342432)) + assert.Equal(t, "23,342,432", PrettyNumber(int32(23342432))) assert.Equal(t, "0", PrettyNumber(0)) assert.Equal(t, "-100,000", PrettyNumber(-100000)) } |