-
Notifications
You must be signed in to change notification settings - Fork 5
/
int64.go
40 lines (33 loc) · 930 Bytes
/
int64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package numtow
import (
"github.com/gammban/numtow/lang"
"github.com/gammban/numtow/lang/en"
"github.com/gammban/numtow/lang/kz"
"github.com/gammban/numtow/lang/ru"
)
// Int64 converts number to words
func Int64(number int64, language lang.Lang, options ...interface{}) (words string, err error) {
switch language {
case lang.KZ:
o := kz.ParseOpts(options...)
return kz.Int64(number, o...)
case lang.RU:
o := ru.ParseOpts(options...)
return ru.Int64(number, o...)
case lang.EN:
o := en.ParseOpts(options...)
return en.Int64(number, o...)
case lang.Unknown:
return words, lang.ErrBadLanguage
default:
return words, lang.ErrBadLanguage
}
}
// MustInt64 returns float64 number converted to words or empty string on error.
func MustInt64(number int64, language lang.Lang, options ...interface{}) string {
res, err := Int64(number, language, options...)
if err != nil {
return ""
}
return res
}