Last change
on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago |
Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
371 bytes
|
Line | |
---|
1 | package humanize
|
---|
2 |
|
---|
3 | import "strconv"
|
---|
4 |
|
---|
5 | // Ordinal gives you the input number in a rank/ordinal format.
|
---|
6 | //
|
---|
7 | // Ordinal(3) -> 3rd
|
---|
8 | func Ordinal(x int) string {
|
---|
9 | suffix := "th"
|
---|
10 | switch x % 10 {
|
---|
11 | case 1:
|
---|
12 | if x%100 != 11 {
|
---|
13 | suffix = "st"
|
---|
14 | }
|
---|
15 | case 2:
|
---|
16 | if x%100 != 12 {
|
---|
17 | suffix = "nd"
|
---|
18 | }
|
---|
19 | case 3:
|
---|
20 | if x%100 != 13 {
|
---|
21 | suffix = "rd"
|
---|
22 | }
|
---|
23 | }
|
---|
24 | return strconv.Itoa(x) + suffix
|
---|
25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.