Current time: 04-23-2014, 02:38 PM Hello There, Guest! (LoginRegister)


[F] Syndication: Atom and RSS different time [C-StefanT]
07-21-2009, 08:53 PM (This post was last modified: 07-21-2009 09:07 PM by querschlaeger.)
Post: #1
[F] Syndication: Atom and RSS different time [C-StefanT]
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.
Visit this user's website Find all posts by this user
07-22-2009, 10:09 PM (This post was last modified: 07-22-2009 10:09 PM by Flex.)
Post: #2
RE: Syndication: Atom and RSS different time
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.
Find all posts by this user
08-13-2009, 08:10 PM (This post was last modified: 08-13-2009 08:54 PM by Ryan Gordon.)
Post: #3
RE: Syndication: Atom and RSS different time
In inc/class_feedgeneration.php find:

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

replace with

PHP Code:
$this->channel['date'] = gmdate("D, d M Y H:i:s O"$this->channel['date']); 
Visit this user's website Find all posts by this user
08-13-2009, 08:11 PM
Post: #4
[F] Syndication: Atom and RSS different time
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
Visit this user's website Find all posts by this user
08-13-2009, 08:37 PM (This post was last modified: 08-13-2009 08:54 PM by frostschutz.)
Post: #5
RE: [F] Syndication: Atom and RSS different time
This user has been denied support. This user has been denied support.
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.

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user
08-13-2009, 08:54 PM
Post: #6
RE: [F] Syndication: Atom and RSS different time
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
Visit this user's website Find all posts by this user
08-13-2009, 09:54 PM (This post was last modified: 08-13-2009 09:58 PM by frostschutz.)
Post: #7
RE: [F] Syndication: Atom and RSS different time
This user has been denied support. This user has been denied support.
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):

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

EDIT: mixed up gmdate and date

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user
08-13-2009, 10:35 PM
Post: #8
RE: [F] Syndication: Atom and RSS different time
That doesn't look like a very good fix :\
Visit this user's website Find all posts by this user
08-13-2009, 10:56 PM (This post was last modified: 08-13-2009 11:01 PM by frostschutz.)
Post: #9
RE: [F] Syndication: Atom and RSS different time
This user has been denied support. This user has been denied support.
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):

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

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication