Give a small tolerence to timestamps in the future when displaying times as 'minutes ago'

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9170 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Chris Smith 2008-12-04 12:56:12 +00:00
parent 866e4196f4
commit 23d9700f07

View file

@ -2028,7 +2028,8 @@ class user extends session
static $date_cache;
$format = (!$format) ? $this->date_format : $format;
$delta = time() - $gmepoch;
$now = time();
$delta = $now - $gmepoch;
if (!isset($date_cache[$format]))
{
@ -2048,10 +2049,11 @@ class user extends session
}
}
// Show date < 1 hour ago as 'xx min ago'
if ($delta <= 3600 && $delta && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
// Show date <= 1 hour ago as 'xx min ago'
// A small tolerence is given for times in the future and times in the future but in the same minute are displayed as '< than a minute ago'
if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
{
return $this->lang(array('datetime', 'AGO'), (int) floor($delta / 60));
return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
}
if (!$midnight)