v0.0.576
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m26s

This commit is contained in:
Mike Schwörer 2025-05-18 14:26:24 +02:00
parent 49bc52d63e
commit a93b93a3cd
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 33 additions and 4 deletions

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.575"
const GoextVersion = "0.0.576"
const GoextVersionTimestamp = "2025-05-11T19:17:05+0200"
const GoextVersionTimestamp = "2025-05-18T14:26:24+0200"

View File

@ -43,8 +43,8 @@ func FormatNaturalDurationEnglish(iv time.Duration) string {
}
}
if min := int64(iv.Minutes()); min < 180 {
return fmt.Sprintf("%d minutes ago", min)
if mins := int64(iv.Minutes()); mins < 180 {
return fmt.Sprintf("%d minutes ago", mins)
}
if hours := int64(iv.Hours()); hours < 72 {
@ -66,3 +66,32 @@ func FormatNaturalDurationEnglish(iv time.Duration) string {
years := int64(iv.Hours() / 24.0 / 7.0 / 365)
return fmt.Sprintf("%d years ago", years)
}
func FormatDurationGerman(iv time.Duration) string {
if sec := int64(iv.Seconds()); sec < 180 {
return fmt.Sprintf("%d s", sec)
}
if mins := int64(iv.Minutes()); mins < 180 {
return fmt.Sprintf("%d min", mins)
}
if hours := int64(iv.Hours()); hours < 72 {
return fmt.Sprintf("%d h", hours)
}
if days := int64(iv.Hours() / 24.0); days < 21 {
return fmt.Sprintf("%d Tage", days)
}
if weeks := int64(iv.Hours() / 24.0 / 7.0); weeks < 12 {
return fmt.Sprintf("%d Wochen", weeks)
}
if months := int64(iv.Hours() / 24.0 / 7.0 / 30); months < 36 {
return fmt.Sprintf("%d Monate", months)
}
years := int64(iv.Hours() / 24.0 / 7.0 / 365)
return fmt.Sprintf("%d Jahre", years)
}