1 Star 0 Fork 0

rancher/harvester

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ordinals.go 371 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jack Yu 提交于 2024-07-25 12:09 +08:00 . chore: go mod vendor
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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rancher/harvester.git
git@gitee.com:rancher/harvester.git
rancher
harvester
harvester
master

搜索帮助