diff --git a/go.mod b/go.mod index 87d6e93..dee5b35 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mergestat/timediff v0.0.3 // indirect github.com/microcosm-cc/bluemonday v1.0.21 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/muesli/cancelreader v0.2.2 // indirect diff --git a/go.sum b/go.sum index 105086a..5432b44 100644 --- a/go.sum +++ b/go.sum @@ -204,6 +204,8 @@ github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mergestat/timediff v0.0.3 h1:ucCNh4/ZrTPjFZ081PccNbhx9spymCJkFxSzgVuPU+Y= +github.com/mergestat/timediff v0.0.3/go.mod h1:yvMUaRu2oetc+9IbPLYBJviz6sA7xz8OXMDfhBl7YSI= github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg= github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= diff --git a/models/post/post.go b/models/post/post.go index 00d903b..ae827db 100644 --- a/models/post/post.go +++ b/models/post/post.go @@ -2,8 +2,10 @@ package post import ( "fmt" + "strings" "time" + "github.com/mergestat/timediff" "github.com/mrusme/gobbs/models/author" "github.com/mrusme/gobbs/models/forum" "github.com/mrusme/gobbs/models/reply" @@ -43,9 +45,9 @@ func (post Post) Title() string { func (post Post) Description() string { return fmt.Sprintf( - "in %s by %s on %s", - post.Forum.Name, + "by %s %s in %s", post.Author.Name, - post.CreatedAt.Local().Format("02 Jan 06 15:04 MST"), + timediff.TimeDiff(post.CreatedAt.Local()), + strings.Title(post.Forum.Name), ) }