Update of /cvsroot/phpwebsite-comm/modules/twitter/class
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3052/class
Modified Files:
Twitter_Runtime.php
Log Message:
PHP4 fix
Index: Twitter_Runtime.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/twitter/class/Twitter_Runtime.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Twitter_Runtime.php 1 Jun 2008 22:51:36 -0000 1.2
--- Twitter_Runtime.php 2 Jun 2008 01:36:33 -0000 1.3
***************
*** 25,28 ****
--- 25,31 ----
class Twitter_Runtime
{
+ /**
+ * Displays the Twitter status on the home page.
+ */
function show()
{
***************
*** 53,57 ****
$status_id = $statuses[$i]['ID'];
$status = array('TEXT' => PHPWS_Text::parseOutput($statuses[$i]['TEXT'], ENCODE_PARSED_TEXT, true),
! 'TIME' => PHPWS_Time::relativeTime(strtotime($statuses[$i]['CREATED_AT'])),
'STATUS_URL' => "http://twitter.com/$user/statuses/$status_id");
$tags['statuses'][] = $status;
--- 56,60 ----
$status_id = $statuses[$i]['ID'];
$status = array('TEXT' => PHPWS_Text::parseOutput($statuses[$i]['TEXT'], ENCODE_PARSED_TEXT, true),
! 'TIME' => PHPWS_Time::relativeTime(Twitter_Runtime::str2time($statuses[$i]['CREATED_AT'])),
'STATUS_URL' => "http://twitter.com/$user/statuses/$status_id");
$tags['statuses'][] = $status;
***************
*** 65,68 ****
--- 68,91 ----
}
}
+
+ /**
+ * Convert a Twitter time string into a timestamp.
+ *
+ * @param string Must be in this format: Sun Jun 01 13:25:50 +0000 2008
+ */
+ function str2time($string)
+ {
+ $time = strtotime($string);
+
+ /* Check for PHP5 or PHP4 error return. */
+ if (($time === false) || ($time < 0))
+ {
+ /* Changing the string order seems to help. */
+ $new_string = substr($string, 0, 11) . substr($string, -4, 4) . substr($string, 10, 15);
+ $time = strtotime($new_string);
+ }
+
+ return $time;
+ }
}
|