diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-15 11:26:40 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-15 11:26:40 +0100 |
commit | 18da28adc1a0559c92f81185fc96ef41a0fd57a3 (patch) | |
tree | cf000f9b372c21990c149b517ffedacf7c47933f | |
parent | e51c1c0156538d07d1eb1bf15a334c5164401448 (diff) |
rss: refactor item date generation
-rw-r--r-- | data/rbot/plugins/rss.rb | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 8004cb12..fc6dfd71 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -982,6 +982,14 @@ class RSSFeedsPlugin < Plugin return seconds end + def make_date(obj) + if obj.kind_of? Time + obj.strftime("%Y/%m/%d %H:%M") + else + obj.to_s + end + end + def printFormattedRss(feed, item, options={}) # debug item opts = { @@ -999,29 +1007,13 @@ class RSSFeedsPlugin < Plugin if opts[:date] if item.respond_to?(:updated) - if item.updated.content.class <= Time - date = item.updated.content.strftime("%Y/%m/%d %H:%M") - else - date = item.updated.content.to_s - end + date = make_date(item.updated.content) elsif item.respond_to?(:source) and item.source.respond_to?(:updated) - if item.source.updated.content.class <= Time - date = item.source.updated.content.strftime("%Y/%m/%d %H:%M") - else - date = item.source.updated.content.to_s - end + date = make_date(item.source.updated.content) elsif item.respond_to?(:pubDate) - if item.pubDate.class <= Time - date = item.pubDate.strftime("%Y/%m/%d %H:%M") - else - date = item.pubDate.to_s - end + date = make_date(item.pubDate) elsif item.respond_to?(:date) - if item.date.class <= Time - date = item.date.strftime("%Y/%m/%d %H:%M") - else - date = item.date.to_s - end + date = make_date(item.date) else date = "(no date)" end |