[ php-blog-Bugs-1904377 ] XMLRPC plugin doesn't respect GMT

"SourceForge.net" <[email protected]> Wed, 05 Mar 2008 16:47:19 -0800
Newsgroups gmane.comp.serendipity.trackers
Message-ID <[email protected]>
Bugs item #1904377, was opened at 2008-02-29 11:43
Message generated for change (Comment added) made by tzi
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=542822&aid=1904377&group_id=75065

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Plugins
Group: None
Status: Closed
Resolution: Fixed
Priority: 1
Private: No
Submitted By: Mike Tyson (tzi)
Assigned to: Garvin Hicking (garvinhicking)
Summary: XMLRPC plugin doesn't respect GMT

Initial Comment:
Currently, the XMLRPC plugin assumes all times are localtime.  This is a bummer when using clients that support sending in GMT (which means we don't have to muck around with timezone stuff).

It's very simple to support GMT - the PEAR XML library already does it.  So the only change required is serendipity_xmlrpc.inc.php, line 523

Change

        $entry['timestamp']  = XML_RPC_iso8601_decode($post_array['dateCreated']);


to

        $entry['timestamp']  = XML_RPC_iso8601_decode($post_array['dateCreated'], ($post_array['dateCreated']{strlen($post_array['dateCreated'])-1} == "Z"));


Voila!  GMT dates sent in is08601 have a Z as the last character, we test for that, and pass it into the $utc parameter for the decode function, which makes it use gmmktime instead of just mktime.


Also, we can support encoding in GMT as well - same file, lines: 139, 234, 274, 569, 706 - wherever we're doing an XML_RPC_iso8601_encode, changing 

...XML_RPC_iso8601_encode($entry['timestamp'])...


to

...XML_RPC_iso8601_encode($entry['timestamp'], true)."Z"...

The "Z" format is part of ISO8601, so it's legal - the only question is how well it's understood by clients.  My client, Ecto, works wonderfully with it - I've always had so much pain dealing with timestamps - I've had to edit in the s9y interface because the time always got mucked up.  This way, it's perfect.

Perhaps you could add the above, but make an option for it in the xmlrpc plugin settings.



----------------------------------------------------------------------

>Comment By: Mike Tyson (tzi)
Date: 2008-03-06 11:47

Message:
Logged In: YES 
user_id=662514
Originator: YES

Looks good Garvin! Just updated and all is well, as far as I can tell.


----------------------------------------------------------------------

Comment By: Garvin Hicking (garvinhicking)
Date: 2008-03-03 23:12

Message:
Logged In: YES 
user_id=473563
Originator: NO

Hi!

Thanks a lot, I just committed your suggestion. Please test :)

Regards,
Garvin

----------------------------------------------------------------------

Comment By: Mike Tyson (tzi)
Date: 2008-02-29 11:49

Message:
Logged In: YES 
user_id=662514
Originator: YES

Oh, I was unclear - the correct parsing of dates with GMT should be done
all the time.

Only the sending of GMT dates should be associated with an option, if
that's the way you decide to go =)

Also, I only included info on how to support GMT for the MT protocol -
it's worth doing a quick search for wherever it does an iso8601_decode and
change other instances of it too.

Cheers!

----------------------------------------------------------------------

Comment By: Mike Tyson (tzi)
Date: 2008-02-29 11:49

Message:
Logged In: YES 
user_id=662514
Originator: YES

Oh, I was unclear - the correct parsing of dates with GMT should be done
all the time.

Only the sending of GMT dates should be associated with an option, if
that's the way you decide to go =)

Also, I only included info on how to support GMT for the MT protocol -
it's worth doing a quick search for wherever it does an iso8601_decode and
change other instances of it too.

Cheers!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=542822&aid=1904377&group_id=75065

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/