Skip Menu |

This queue is for tickets about the Bryar CPAN distribution.

Report information
The Basics
Id: 5016
Status: resolved
Priority: 0/
Queue: Bryar

People
Owner: Nobody in particular
Requestors: steve [...] fisharerojo.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Post_calendar creates calendar incorrectly using gmtime
In the function posts_calendar in Bryar.pm, the calendar uses gmtime to determine the dates on for the posts my %posts = map { (gmtime($_->{epoch}))[3] => $_->{id} } @documents; This will produce a calendar that my be correct for GMT, but the posts may be listed on the incorrect date if you are in a difference time zone. Simply replacing the gmtime with localtime in the line above fixes the problem.
Date: Fri, 23 Jan 2004 17:27:33 +0000
From: Simon Cozens <simon [...] simon-cozens.org>
To: via RT <bug-Bryar [...] rt.cpan.org>
Subject: Re: [cpan #5016] Post_calendar creates calendar incorrectly using gmtime
RT-Send-Cc:
via RT: Show quoted text
> This will produce a calendar that my be correct for GMT, but the posts may be listed on the incorrect date if you are in a difference time zone. Simply replacing the gmtime with localtime in the line above fixes the problem.
Thanks, I'll apply that. In exchange, can you look at your own atom template, which seems to give errors when tzoffset is 0 (such as in GMT) as it uses this value as a modulus. -- On our campus the UNIX system has proved to be not only an effective software tool, but an agent of technical and social change within the University. - John Lions (U. of NSW)
From: steve [...] fisharerojo.org
[simon@simon-cozens.org - Fri Jan 23 12:27:39 2004]: Show quoted text
> Thanks, I'll apply that. In exchange, can you look at your own atom > template, > which seems to give errors when tzoffset is 0 (such as in GMT) as it > uses this value as a modulus.
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.
From: Steve Peters
[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
I think this is now fixed; (at least in CVS) please reopen the ticket if not. SOrry for the delay.