mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
better unit detection
This commit is contained in:
parent
b219ccfe68
commit
cc839f935d
|
@ -145,6 +145,21 @@ func SecondsToTTL(seconds int32) string {
|
||||||
if seconds == 0 {
|
if seconds == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
if seconds%(3600*24*365) == 0 && seconds/(3600*24*365) < 256 {
|
||||||
|
return fmt.Sprintf("%dy", seconds/(3600*24*365))
|
||||||
|
}
|
||||||
|
if seconds%(3600*24*30) == 0 && seconds/(3600*24*30) < 256 {
|
||||||
|
return fmt.Sprintf("%dM", seconds/(3600*24*30))
|
||||||
|
}
|
||||||
|
if seconds%(3600*24*7) == 0 && seconds/(3600*24*7) < 256 {
|
||||||
|
return fmt.Sprintf("%dw", seconds/(3600*24*7))
|
||||||
|
}
|
||||||
|
if seconds%(3600*24) == 0 && seconds/(3600*24) < 256 {
|
||||||
|
return fmt.Sprintf("%dd", seconds/(3600*24))
|
||||||
|
}
|
||||||
|
if seconds%(3600) == 0 && seconds/(3600) < 256 {
|
||||||
|
return fmt.Sprintf("%dh", seconds/(3600))
|
||||||
|
}
|
||||||
if seconds/60 < 256 {
|
if seconds/60 < 256 {
|
||||||
return fmt.Sprintf("%dm", seconds/60)
|
return fmt.Sprintf("%dm", seconds/60)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue