From c6a78164358f4d6fe84e89a338395887a45c454f Mon Sep 17 00:00:00 2001 From: Sean Schulte Date: Mon, 24 Mar 2014 21:58:36 -0500 Subject: [PATCH] Back to previous API. (IE, the previous breaking changes are unbroken.) --- atom.go | 2 +- item.go | 10 +++++++--- rss.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/atom.go b/atom.go index 37f568c..cab3935 100644 --- a/atom.go +++ b/atom.go @@ -56,7 +56,7 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) { i = new(Item) i.Title = item.S(ns, "title") i.Id = item.S(ns, "id") - i.PubDate, _ = parseTime(item.S(ns, "updated")) + i.PubDate = item.S(ns, "updated") i.Description = item.S(ns, "summary") links := item.SelectNodes(ns, "link") diff --git a/item.go b/item.go index 5c002f7..f572a75 100644 --- a/item.go +++ b/item.go @@ -16,7 +16,7 @@ type Item struct { Comments string Enclosures []*Enclosure Guid *string - PubDate time.Time + PubDate string Source *Source // Atom specific fields @@ -28,14 +28,18 @@ type Item struct { Extensions map[string]map[string][]Extension } +func (i *Item) ParsedPubDate() (time.Time, error) { + return parseTime(i.PubDate) +} + func (i *Item) Key() string { switch { case i.Guid != nil && len(*i.Guid) != 0: return *i.Guid case len(i.Id) != 0: return i.Id - case len(i.Title) > 0 && !i.PubDate.IsZero(): - return i.Title + i.PubDate.String() + case len(i.Title) > 0 && len(i.PubDate) > 0: + return i.Title + i.PubDate default: h := md5.New() io.WriteString(h, i.Description) diff --git a/rss.go b/rss.go index e5e749f..1c347ca 100644 --- a/rss.go +++ b/rss.go @@ -162,7 +162,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) { i.Guid = &guid } - i.PubDate, _ = parseTime(item.S(ns, "pubDate")) + i.PubDate = item.S(ns, "pubDate") tl = item.SelectNodes(ns, "category") for _, lv := range tl {