aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/item.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-07 00:13:34 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-07 00:13:34 +0200
commit345887f3c8319c6dd91f20cd75615fd5c9fcf460 (patch)
tree7adb89358d95067d46cf011771502984b9002b3a /internal/feed/item.go
parent1bb9b56b214128cd98aabe66b41d0a05da3a0b05 (diff)
downloadfeed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.tar.gz
feed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.tar.bz2
feed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.zip
Unified publishedDate and updatedDate into one (just as the old feed2imap...)
Diffstat (limited to '')
-rw-r--r--internal/feed/item.go15
1 files changed, 15 insertions, 0 deletions
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 {