Use preferably the published date for Atom feeds

YouTube feeds use the published date for the original creation date.
This commit is contained in:
Frédéric Guillot 2019-01-29 20:01:36 -08:00
parent c71681b197
commit ed6ae7e0d2
2 changed files with 7 additions and 3 deletions

View File

@ -130,9 +130,13 @@ func getRelationURL(links []atomLink, relation string) string {
}
func getDate(a *atomEntry) time.Time {
dateText := a.Updated
// Note: The published date represents the original creation date for YouTube feeds.
// Example:
// <published>2019-01-26T08:02:28+00:00</published>
// <updated>2019-01-29T07:27:27+00:00</updated>
dateText := a.Published
if dateText == "" {
dateText = a.Published
dateText = a.Updated
}
if dateText != "" {

View File

@ -546,7 +546,7 @@ func TestParseEntryWithPublishedAndUpdated(t *testing.T) {
t.Error(err)
}
if !feed.Entries[0].Date.Equal(time.Date(2003, time.December, 13, 18, 30, 2, 0, time.UTC)) {
if !feed.Entries[0].Date.Equal(time.Date(2002, time.November, 12, 18, 30, 2, 0, time.UTC)) {
t.Errorf("Incorrect entry date, got: %v", feed.Entries[0].Date)
}
}