mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-23 08:34:17 +02:00
Use "just now" rather than seconds for documents under 1 minute old
This commit is contained in:
parent
40724af7e1
commit
d9b1d335d4
1 changed files with 4 additions and 1 deletions
|
|
@ -845,7 +845,10 @@ var magnitudes = []humanize.RelTimeMagnitude{
|
|||
|
||||
func relativeTime(then time.Time) string {
|
||||
now := time.Now()
|
||||
if now.Sub(then) < humanize.Week {
|
||||
ago := now.Sub(then)
|
||||
if ago < time.Minute {
|
||||
return "just now"
|
||||
} else if ago < humanize.Week {
|
||||
return humanize.CustomRelTime(then, now, "ago", "from now", magnitudes)
|
||||
}
|
||||
return then.Format("02 Jan 2006 15:04 MST")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue