mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Improve time since post date displays
- 15 days now is "15 days" rather than "3 weeks" ago. - 32 days is now "1 month" rather than "2 months" ago. - 366 days is now "1 year" rather than "2 years" ago. Closes #267
This commit is contained in:
parent
5cd7152ae7
commit
3d04d92aa2
2 changed files with 9 additions and 5 deletions
|
@ -162,16 +162,16 @@ func elapsedTime(printer *locale.Printer, tz string, t time.Time) string {
|
|||
return printer.Plural("time_elapsed.hours", hours, hours)
|
||||
case d == 1:
|
||||
return printer.Printf("time_elapsed.yesterday")
|
||||
case d < 7:
|
||||
case d < 21:
|
||||
return printer.Plural("time_elapsed.days", d, d)
|
||||
case d < 31:
|
||||
weeks := int(math.Ceil(float64(d) / 7))
|
||||
weeks := int(math.Round(float64(d) / 7))
|
||||
return printer.Plural("time_elapsed.weeks", weeks, weeks)
|
||||
case d < 365:
|
||||
months := int(math.Ceil(float64(d) / 30))
|
||||
months := int(math.Round(float64(d) / 30))
|
||||
return printer.Plural("time_elapsed.months", months, months)
|
||||
default:
|
||||
years := int(math.Ceil(float64(d) / 365))
|
||||
years := int(math.Round(float64(d) / 365))
|
||||
return printer.Plural("time_elapsed.years", years, years)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue