mirror of
https://github.com/go-gitea/gitea
synced 2024-10-31 16:53:25 +01:00
20c513be6e
* Show download count info in release list * Use go-humanize
26 lines
371 B
Go
Vendored
26 lines
371 B
Go
Vendored
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
|
|
}
|