MyBB Community Forums

Full Version: [F] Syndication: Atom and RSS different time [C-StefanT]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

it seems that RSS feed and Atom feed shows different times:

http://community.mybboard.net/syndication.php
http://community.mybboard.net/syndicatio...pe=atom1.0

In this board 5 hours. The Atom feed seems to ignore the time difference.
ATOM is using gmdate() to calculate the current date, though I can't find any information in the RFC demanding for this.

http://www.atompub.org/rfc4287.html#date.constructs

It is class_feedgeneration.php, Line 93.
In inc/class_feedgeneration.php find:

$this->channel['date'] = date("D, d M Y H:i:s O", $this->channel['date']);

replace with

$this->channel['date'] = gmdate("D, d M Y H:i:s O", $this->channel['date']);
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group
I'm not using RSS Feeds myself so I'm not sure about this issue, but you're specifying dates as being in the Z timezone (which means UTC, formerly known as GMT), so gmdate should be correct.

For local time, the timezone has to be specified in +hh:mm format.

Maybe quality assurance team can test wether items in both RSS / Atom show up with the correct date? Needs a board with local time different from UTC/GMT, and a RSS reader that displays the date...

http://www.w3.org/TR/NOTE-datetime Wrote:1. Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator ("Z").
2. Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of "+hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes ahead of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes behind UTC.
Okay, updated the fix with gmdate instead. Is that better? I'm not sure what to do with the "Z" option yet in the RSS format
Oh, sorry. Since you posted the code above, I noticed the O option (which returns +0200). I didn't know PHP date supported this, quote from php.net date doc:

Quote:O Difference to Greenwich time (GMT) in hours Example: +0200
P Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00

So actually if you use O, it's fine to use date() instead of gmdate(). The gmdate() version is not wrong either (O will just return +0000 then), but date() then has the advantage of being able to tell the user which part (timezone) of the world this thing originated from.

For Atom, you'd have to use P instead of O (instead of \Z), since the : is required (sucks how many different date time RFCs there are), too bad the P was only added in PHP 5.1, so with older versions of PHP you have to cheat the missing : in there somewhere.

So actually as far as I can tell the code as of MyBB 1.4.8 is not wrong, both RSS and Atom specify the correct time (as in, the same instant), the only difference is that they specify the same instant in different time zones.

So the fix could actually be something similar to this for the atom part (code not tested at all):

$somedate = date("Y-m-d\TH:i:sO", $this->channel['date']);
$somedate = substr($somedate, 0, strlen($somedate)-2) . ":" . substr($somedate, -2);
$this->channel['date'] = $somedate;

EDIT: mixed up gmdate and date
That doesn't look like a very good fix :\
The code does not look nice (only wrote it as example, without testing it), but it produces the correct result "2009-08-14T00:54:09+02:00"

Dunno if there's a nicer way to insert : into the string. Well, there is P, but not an option with PHP < 5.1.3.
Nicer looking version (but not tested):

$this->channel['date'] = substr_replace(date("Y-m-d\TH:i:sO", $this->channel['date']), ":", -2, 0);