Fix duration saying never when it's unlimited

This commit is contained in:
2026-09-13 09:10:46 +02:00
parent e7344f8aab
commit b24467c37d
5 changed files with 22 additions and 4 deletions
+10
View File
@@ -103,6 +103,16 @@ func ParseDuration(s string) (time.Duration, error) {
return d, nil
}
// FormatLifetime renders a lifetime *limit*, where FormatDuration's "never"
// would describe the wrong thing: a ceiling of Unlimited is not a file that
// never expires, it is the absence of a ceiling.
func FormatLifetime(d time.Duration) string {
if d == Unlimited {
return "unlimited"
}
return FormatDuration(d)
}
// FormatDuration is the human-facing inverse of ParseDuration.
func FormatDuration(d time.Duration) string {
switch {