1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2024-12-29 00:36:32 +00:00
imgsrv/vendor/github.com/dustin/go-humanize/ordinals.go
Vincent Batts 3c732c3b43
vendoring sources, for posterity sake
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2019-03-11 15:31:42 -04:00

25 lines
371 B
Go

package humanize
import "strconv"
// Ordinal gives you the input number in a rank/ordinal format.
//
// Ordinal(3) -> 3rd
func Ordinal(x int) string {
suffix := "th"
switch x % 10 {
case 1:
if x%100 != 11 {
suffix = "st"
}
case 2:
if x%100 != 12 {
suffix = "nd"
}
case 3:
if x%100 != 13 {
suffix = "rd"
}
}
return strconv.Itoa(x) + suffix
}