The Joomla! Forum ™



Forum rules


Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: Tue Oct 06, 2009 1:40 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Fri Sep 16, 2005 9:13 am
Posts: 433
Description:
When using $local=true, the JDate::toRFC822() method correctly calculates the date and time with the offset. However is always outputs '+0000' at the end of the returned string. The JDate::toISO8601() method on the other hand correctly evaluates this and appends the offset in the form +00:00.

Reported on:
J!1.5

Related files:
libraries/joomla/html/html.php

Proposed fix(es):
I have created a patch to resolve this problem. This patch borrows code from JDate::toISO8601() with a few tweaks. To test the patch try the following before and after applying:

Code:
// get now
$now = JFactory::getDate();

echo 'UTC+0:'.$now->toRFC822();
echo '<p>';

$now->setOffset(1);
echo 'UTC+1:'.$now->toRFC822(true);
echo '<p>';

$now->setOffset(-1);
echo 'UTC-1:'.$now->toRFC822(true);


You do not have the required permissions to view the files attached to this post.

_________________
Signature Rules viewtopic.php?f=8&t=65


Top
 Profile  
 
PostPosted: Wed Oct 07, 2009 10:09 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Fri Sep 16, 2005 9:13 am
Posts: 433
Just spotted another problem with JDate. The constructor attempts to parse a number of different date and time formats, including RFC 2822. There is a minor error in the way in which it deals with mililtary time zones - http://www.timeanddate.com/library/abbreviations/timezones/military/.

Militay time zones are expressed as aplha letters from A - Z. JDate processes as one of three types, A-L, [URL banned] and Z. However the way in A-L and [URL banned] are slected is flawed. For example if the offset were defined as "[" (an illegal char in an RFC 2822 value) JDate will incorrectly evaluate this as in the range N-Y. Here is the problem area:

Code:
$ord = ord($matches[7]);
if ($ord < ord('M')) {
   $tzOffset = (ord('A') - $ord - 1) * $oneHour;
} elseif ($ord >= ord('M') && $matches[7] != 'Z') {
   $tzOffset = ($ord - ord('M')) * $oneHour;
} elseif ($matches[7] == 'Z') {
   $tzOffset = 0;
}


This should be:

Code:
$ord = ord($matches[7]);
if ($ord < ord('M') && $ord >= ord('A')) {
   $tzOffset = (ord('A') - $ord - 1) * $oneHour;
} elseif ($ord >= ord('M') $ord < ord('Z')) {
   $tzOffset = ($ord - ord('M')) * $oneHour;
} elseif ($matches[7] == 'Z') {
   $tzOffset = 0;
}

_________________
Signature Rules viewtopic.php?f=8&t=65


Top
 Profile  
 
PostPosted: Wed Oct 07, 2009 10:12 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Fri Sep 16, 2005 9:13 am
Posts: 433
I should also point out that there is a major lack of comments in the JDate constructor. This makes it really hard to understand looking at it for the first time. This bit of code would rteally benefit from some code comments. If I can help recitify this let me know.

_________________
Signature Rules viewtopic.php?f=8&t=65


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group