mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Make sure livestamp' is only active when 'relative' is selected in toDate().
This commit is contained in:
@@ -660,7 +660,7 @@ class convert
|
|||||||
*
|
*
|
||||||
* @param string $str date string to parse (e.g. returned from strftime()).
|
* @param string $str date string to parse (e.g. returned from strftime()).
|
||||||
* @param string $sFormat strftime format used to create the date
|
* @param string $sFormat strftime format used to create the date
|
||||||
* @return array Returns an array with the <code>$str</code> parsed, or <code>false</code> on error.
|
* @return array|bool Returns an array with the <code>$str</code> parsed, or <code>false</code> on error.
|
||||||
*/
|
*/
|
||||||
public function strptime($str, $format)
|
public function strptime($str, $format)
|
||||||
{
|
{
|
||||||
@@ -719,6 +719,8 @@ class convert
|
|||||||
preg_match_all('/(%\w)/', $format, $positions);
|
preg_match_all('/(%\w)/', $format, $positions);
|
||||||
$positions = $positions[1];
|
$positions = $positions[1];
|
||||||
|
|
||||||
|
$vals = array();
|
||||||
|
|
||||||
#-- get individual values
|
#-- get individual values
|
||||||
if (preg_match("#$preg#", $str, $extracted))
|
if (preg_match("#$preg#", $str, $extracted))
|
||||||
{
|
{
|
||||||
@@ -797,7 +799,7 @@ class convert
|
|||||||
//var_dump($vals, $str, strftime($format, $unxTimestamp), $unxTimestamp);
|
//var_dump($vals, $str, strftime($format, $unxTimestamp), $unxTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isset($vals) ? $vals : false;
|
return !empty($vals) ? $vals : false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4740,13 +4740,17 @@ class e_parser
|
|||||||
* Includes support for 'livestamp' (http://mattbradley.github.io/livestampjs/)
|
* Includes support for 'livestamp' (http://mattbradley.github.io/livestampjs/)
|
||||||
* @param integer $datestamp - unix timestamp
|
* @param integer $datestamp - unix timestamp
|
||||||
* @param string $format - short | long | relative
|
* @param string $format - short | long | relative
|
||||||
* @return HTML with converted date.
|
* @return string converted date (html)
|
||||||
*/
|
*/
|
||||||
public function toDate($datestamp = null, $format='short')
|
public function toDate($datestamp = null, $format='short')
|
||||||
{
|
{
|
||||||
if(!is_numeric($datestamp)){ return null; }
|
if(!is_numeric($datestamp)){ return null; }
|
||||||
|
|
||||||
return '<span data-livestamp="'.$datestamp.'">'.e107::getDate()->convert($datestamp, $format).'</span>';
|
$value = e107::getDate()->convert_date($datestamp, $format);
|
||||||
|
|
||||||
|
$inc = ($format === 'relative') ? ' data-livestamp="'.$datestamp.'"' : '';
|
||||||
|
|
||||||
|
return '<span'.$inc.'>'.$value.'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user