From 345887f3c8319c6dd91f20cd75615fd5c9fcf460 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Thu, 7 May 2020 00:13:34 +0200 Subject: Unified publishedDate and updatedDate into one (just as the old feed2imap...) --- internal/feed/item.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/feed/item.go') diff --git a/internal/feed/item.go b/internal/feed/item.go index bbf7668..8b747fb 100644 --- a/internal/feed/item.go +++ b/internal/feed/item.go @@ -3,6 +3,7 @@ package feed import ( "encoding/base64" "fmt" + "time" "github.com/google/uuid" "github.com/mmcdole/gofeed" @@ -27,6 +28,20 @@ type item struct { itemId uuid.UUID } +func (item *item) DateParsed() *time.Time { + if item.UpdatedParsed == nil || item.UpdatedParsed.IsZero() { + return item.PublishedParsed + } + return item.UpdatedParsed +} + +func (item *item) Date() string { + if item.Updated == "" { + return item.Published + } + return item.Updated +} + // Creator returns the name of the creating author. func (item *item) Creator() string { if item.Author != nil { -- cgit v1.2.3-70-g09d2