fix(redisset): parse Published date without colon as well
All checks were successful
continuous-integration/drone/push Build is passing

Some feeds include a timezone without a colon ":". This changes makes it
so this is parsed as well.
This commit is contained in:
Peter Stuifzand 2021-10-20 21:37:10 +02:00
parent 9df63af33c
commit 2f0758748d
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -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)