Cope with "updated" and "published" elements
Simon Wistow [Fri, 22 Aug 2008 22:17:32 +0000 (22:17 +0000)]
http://rt.cpan.org/Public/Bug/Display.html?id=20763
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=380498
(Gregor Herrmann and Joey Hess)

Changes
lib/XML/Feed/Atom.pm

diff --git a/Changes b/Changes
index b0e7d04..e9b2f3b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,7 @@ Revision history for XML::Feed
     - Allow specification of the parsing format. Fixes bugs
       http://rt.cpan.org/Public/Bug/Display.html?id=35580 and
       http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477394
+      (Gregor Herrmann and Martin F Krafft)
     - Allow pass through of initialisation options
       http://rt.cpan.org/Public/Bug/Display.html?id=24729
       (Christopher H. Laco CLACO)
@@ -18,6 +19,10 @@ Revision history for XML::Feed
     - Prevent empty content
       http://rt.cpan.org/Public/Bug/Display.html?id=29684
       (Dave Rolsky DROLSKY)
+    - Cope with "updated" and "published" elements
+      http://rt.cpan.org/Public/Bug/Display.html?id=20763
+      http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=380498
+      (Gregor Herrmann and Joey Hess)
   
 0.12  2006.08.13
     - Generate Atom 1.0 feeds by default. Thanks to Tatsuhiko Miyagawa for
index 5231c14..9ca9b0c 100644 (file)
@@ -64,7 +64,9 @@ sub modified {
     if (@_) {
         $feed->{atom}->modified(DateTime::Format::W3CDTF->format_datetime($_[0]));
     } else {
-        $feed->{atom}->modified ? iso2dt($feed->{atom}->modified) : undef;
+        return iso2dt($feed->{atom}->modified) if $feed->{atom}->modified;
+        return iso2dt($feed->{atom}->updated)  if $feed->{atom}->updated;
+        return undef;
     }
 }
 
@@ -189,7 +191,9 @@ sub modified {
     if (@_) {
         $entry->{entry}->modified(DateTime::Format::W3CDTF->format_datetime($_[0])) if $_[0];
     } else {
-        $entry->{entry}->modified ? iso2dt($entry->{entry}->modified) : undef;
+        return iso2dt($entry->{entry}->modified) if $entry->{entry}->modified;
+        return iso2dt($entry->{entry}->updated)  if $entry->{entry}->updated;
+        return undef;
     }
 }