Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
98c591b019
|
|||
a93b93a3cd
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.575"
|
const GoextVersion = "0.0.577"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2025-05-11T19:17:05+0200"
|
const GoextVersionTimestamp = "2025-05-18T21:42:18+0200"
|
||||||
|
@@ -43,8 +43,8 @@ func FormatNaturalDurationEnglish(iv time.Duration) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if min := int64(iv.Minutes()); min < 180 {
|
if mins := int64(iv.Minutes()); mins < 180 {
|
||||||
return fmt.Sprintf("%d minutes ago", min)
|
return fmt.Sprintf("%d minutes ago", mins)
|
||||||
}
|
}
|
||||||
|
|
||||||
if hours := int64(iv.Hours()); hours < 72 {
|
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)
|
years := int64(iv.Hours() / 24.0 / 7.0 / 365)
|
||||||
return fmt.Sprintf("%d years ago", years)
|
return fmt.Sprintf("%d years ago", years)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormatDurationGerman(iv time.Duration) string {
|
||||||
|
if sec := int64(iv.Seconds()); sec < 180 {
|
||||||
|
return fmt.Sprintf("%ds", sec)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mins := int64(iv.Minutes()); mins < 180 {
|
||||||
|
return fmt.Sprintf("%dmin", mins)
|
||||||
|
}
|
||||||
|
|
||||||
|
if hours := int64(iv.Hours()); hours < 72 {
|
||||||
|
return fmt.Sprintf("%dh", 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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user