[guest - Fri Jan 23 15:11:51 2004]:
Show quoted text> Great, burnt by the same bug I keep finding elsewhere ;). I've got an
> idea how to fix it and should have a new patch ready this evening.
After some additional reading of Atom feed spec, I realized I made a
mistake by looking at feeds across the Internet as examples. The spec
is at
http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.4.9
It specifies that the modified date element of the feed must be in UTC.
The other dates should be UTC according to the spec. Therefore, the
new patch for Atom feeds will follow the spec.
To do this, I added a utctimepiece function to Bryar/Document.pm. I
know the name is bad, so change it if you wish. Just remember to change
the template.atom file. The template now just uses UTC times which
makes it much less complex than trying to calculate the offset minutes
correctly for a small number of time zones.
Attached is the patch. The only know issue is that it doesn't support
subblogs, but neither do the RSS feed or permalinks. That would require
some modifications to make_document function on the DataSource classes
which is more than I want to take on for a quick patch.
diff -ur Bryar-2.3/bryar-newblog myBryar-2.3/bryar-newblog
--- Bryar-2.3/bryar-newblog 2004-01-23 07:29:55.000000000 -0600
+++ myBryar-2.3/bryar-newblog 2004-01-23 21:05:14.000000000 -0600
@@ -217,7 +217,7 @@
<title>[% bryar.config.name %]</title>
<link rel="alternate" type="text/html"
href="[% bryar.config.baseurl %]"/>
- <modified>[%documents.first.timepiece.datetime%][% FILTER format("%03d") %][% documents.first.timepiece.tzoffset / 3600 %][%END%]:00</modified>
+ <modified>[% documents.first.utctimepiece.datetime _ 'Z' %]</modified>
<author>
<name>[% bryar.config.author %]</name>
</author>
@@ -228,10 +228,8 @@
href="[%bryar.config.baseurl _ "/id_" _ item.id %]"/>
[% idURL = bryar.config.baseurl | replace('http://', '') | replace('/.*', '') %]
<id>tag:[% idURL _ "," _ item.timepiece.year _":id_" _ item.id %]</id>
- [% hours = item.timepiece.tzoffset / 3600 %]
- [% minutes = (item.timepiece.tzoffset % (hours * 60 * 60)) / 60 %]
- <issued>[% item.timepiece.datetime %][% FILTER format("%03d") %][% hours %][%END%]:[% FILTER format("%02d") %][% minutes %][%END%]</issued>
- <modified>[% item.timepiece.datetime %][% FILTER format("%03d") %][% hours %][%END%]:[% FILTER format("%02d") %][% minutes %][%END%]</modified>
+ <issued>[% item.utctimepiece.datetime _ 'Z' %]</issued>
+ <modified>[% item.utctimepiece.datetime _ 'Z' %]</modified>
<summary type="text/plain"> [% FILTER truncate(252) %]
[% item.content | replace('<.*?>', '') %]
[% END %]
diff -ur Bryar-2.3/lib/Bryar/Document.pm myBryar-2.3/lib/Bryar/Document.pm
--- Bryar-2.3/lib/Bryar/Document.pm 2003-06-14 14:56:39.000000000 -0500
+++ myBryar-2.3/lib/Bryar/Document.pm 2004-01-23 20:07:36.000000000 -0600
@@ -18,7 +18,8 @@
$self->title(); # Get title
$self->epoch(); # Get epoch
- $self->timepiece(); # Get the date as a Time::Piece object
+ $self->timepiece(); # Get the date as a Time::Piece object
+ $self->utctimepiece(); # Get the UTC date as a Time::Piece object
$self->category(); # Get category
$self->author(); # Get author
@@ -113,6 +114,20 @@
return Time::Piece->new($self->{epoch});
}
+=head2 utctimepiece
+
+Returns the UTC date of the document as a Time::Piece object.
+
+=cut
+
+sub utctimepiece {
+ my $self = shift;
+ # Time::Piece::gmtime only returns an object to defined scalars
+ my $t = gmtime($self->{epoch});
+ return $t;
+}
+
+
=head2 category
$self->category(); # Get category