mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
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:
parent
866e4196f4
commit
23d9700f07
1 changed files with 6 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue