From 2f0758748dc2a9d9f2cf7a763810507a672fe04e Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Wed, 20 Oct 2021 21:37:10 +0200 Subject: [PATCH] fix(redisset): parse Published date without colon as well Some feeds include a timezone without a colon ":". This changes makes it so this is parsed as well. --- pkg/timeline/redisset.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/timeline/redisset.go b/pkg/timeline/redisset.go index 092c5a2..c84526f 100644 --- a/pkg/timeline/redisset.go +++ b/pkg/timeline/redisset.go @@ -114,6 +114,12 @@ func (timeline *redisSortedSetTimeline) AddItem(item microsub.Item) (bool, error item.Published = time.Now().Format(time.RFC3339) } + // Fix date when it almost matches with RFC3339, except the colon in the timezone + format := "2006-01-02T15:04:05Z0700" + if parsedDate, err := time.Parse(format, item.Published); err == nil { + item.Published = parsedDate.Format(time.RFC3339) + } + data, err := json.Marshal(item) if err != nil { return false, fmt.Errorf("couldn't marshal item for redis: %s", err)