Skip Menu |

This queue is for tickets about the XML-Feed CPAN distribution.

Report information
The Basics
Id: 48337
Status: resolved
Priority: 0/
Queue: XML-Feed

People
Owner: Nobody in particular
Requestors: foucault.online [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 0.54



Subject: Date format invalidates atom feeds
Atom feeds should use the RFC 3339 date time format as described here ( http://validator.w3.org/feed/docs/error/InvalidRFC3339Date.html ). Otherwise the feed cannot be validated against the W3C validation service ( http://validator.w3.org/feed/ ). Currently Atom feeds seem to lack the timezone information (except for <published>). Minimal example -------8<--------- use DateTime; use XML::Feed; use XML::Feed::Entry; my $feed = XML::Feed->new('Atom'); my $dt = DateTime->now(); $feed->title("My Atom feed"); $feed->link("http://www.example.com"); $feed->author("Author"); $feed->updated($dt); $feed->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a"); my $entry = XML::Feed::Entry->new('Atom'); $entry->title("An important event"); $entry->author("Important author"); $entry->content("A very interesting event happened."); $entry->issued($dt); $entry->updated($dt); $entry->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"); $feed->add_entry($entry); print $feed->as_xml . "\n"; ------->8---------- Yields: <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>My Atom feed</title> <link rel="alternate" href="http://www.example.com" type="text/html"/> <author> <name>Author</name> </author> <updated>2009-07-31T00:17:29</updated> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a</id> <entry> <title>An important event</title> <author> <name>Important author</name> </author> <content type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml">A very interesting event happened.</div> </content> <published>2009-07-31T00:17:29Z</published> <updated>2009-07-31T00:17:29</updated> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> </entry> </feed> Validator fails with above output complaining about the dates of <updated>.
On Thu Jul 30 20:25:40 2009, http://spystath.pip.verisignlabs.com/ wrote: Show quoted text
> Atom feeds should use the RFC 3339 date time format as described here ( > http://validator.w3.org/feed/docs/error/InvalidRFC3339Date.html ). > Otherwise the feed cannot be validated against the W3C validation > service ( http://validator.w3.org/feed/ ). > > Currently Atom feeds seem to lack the timezone information (except for > <published>). > > Minimal example > -------8<--------- > use DateTime; > use XML::Feed; use XML::Feed::Entry; > > my $feed = XML::Feed->new('Atom'); > my $dt = DateTime->now(); > > $feed->title("My Atom feed"); > $feed->link("http://www.example.com"); > $feed->author("Author"); > $feed->updated($dt); > $feed->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a"); > > my $entry = XML::Feed::Entry->new('Atom'); > $entry->title("An important event"); > $entry->author("Important author"); > $entry->content("A very interesting event happened."); > > $entry->issued($dt); > $entry->updated($dt); > $entry->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"); > > $feed->add_entry($entry); > > print $feed->as_xml . "\n"; > ------->8---------- > > Yields: > <?xml version="1.0" encoding="utf-8"?> > <feed xmlns="http://www.w3.org/2005/Atom"> > <title>My Atom feed</title> > <link rel="alternate" href="http://www.example.com" type="text/html"/> > <author> > <name>Author</name> > </author> > <updated>2009-07-31T00:17:29</updated> > <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a</id> > <entry> > <title>An important event</title> > <author> > <name>Important author</name> > </author> > <content type="xhtml"> > <div xmlns="http://www.w3.org/1999/xhtml">A very interesting event > happened.</div> > </content> > <published>2009-07-31T00:17:29Z</published> > <updated>2009-07-31T00:17:29</updated> > <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> > </entry> > </feed> > > Validator fails with above output complaining about the dates of
<updated>. This happens because of DateTime::Format::W3CDTF: if your DateTime object has a floating timezone ($dt->is_floating), it won't add the timezone offset to the datetime string. So I've solved this by setting a timezone right before passing it to XML::Feed: $dt->clone->set_time_zone("Your/Timezone");
On Sun Aug 23 15:41:23 2009, salvix wrote: Show quoted text
> On Thu Jul 30 20:25:40 2009, http://spystath.pip.verisignlabs.com/ wrote:
> > Atom feeds should use the RFC 3339 date time format as described here ( > > http://validator.w3.org/feed/docs/error/InvalidRFC3339Date.html ). > > Otherwise the feed cannot be validated against the W3C validation > > service ( http://validator.w3.org/feed/ ). > > > > Currently Atom feeds seem to lack the timezone information (except for > > <published>). > > > > Minimal example > > -------8<--------- > > use DateTime; > > use XML::Feed; use XML::Feed::Entry; > > > > my $feed = XML::Feed->new('Atom'); > > my $dt = DateTime->now(); > > > > $feed->title("My Atom feed"); > > $feed->link("http://www.example.com"); > > $feed->author("Author"); > > $feed->updated($dt); > > $feed->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a"); > > > > my $entry = XML::Feed::Entry->new('Atom'); > > $entry->title("An important event"); > > $entry->author("Important author"); > > $entry->content("A very interesting event happened."); > > > > $entry->issued($dt); > > $entry->updated($dt); > > $entry->id("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"); > > > > $feed->add_entry($entry); > > > > print $feed->as_xml . "\n"; > > ------->8---------- > > > > Yields: > > <?xml version="1.0" encoding="utf-8"?> > > <feed xmlns="http://www.w3.org/2005/Atom"> > > <title>My Atom feed</title> > > <link rel="alternate" href="http://www.example.com" type="text/html"/> > > <author> > > <name>Author</name> > > </author> > > <updated>2009-07-31T00:17:29</updated> > > <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344eaa6a</id> > > <entry> > > <title>An important event</title> > > <author> > > <name>Important author</name> > > </author> > > <content type="xhtml"> > > <div xmlns="http://www.w3.org/1999/xhtml">A very interesting event > > happened.</div> > > </content> > > <published>2009-07-31T00:17:29Z</published> > > <updated>2009-07-31T00:17:29</updated> > > <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> > > </entry> > > </feed> > > > > Validator fails with above output complaining about the dates of
> <updated>. > > > This happens because of DateTime::Format::W3CDTF: if your DateTime > object has a floating timezone ($dt->is_floating), it won't add the > timezone offset to the datetime string. > > So I've solved this by setting a timezone right before passing it to > XML::Feed: > > $dt->clone->set_time_zone("Your/Timezone");
When I explicitly set the timezone, <published> element is correctly turned into "2009-07-31T00:17:29+03:00" but the <updated> elements are rendered without timezone. I noticed though that if I use $entry->modified($dt) instead of $entry->updated($dt) the correct datetime format is used. It seems I mistakenly thought that "updated" and "modified" subs should practically do the same thing, so my bad. Thank you for your time!