aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Smith <toonarmy@phpbb.com>2008-12-04 12:56:12 +0000
committerChris Smith <toonarmy@phpbb.com>2008-12-04 12:56:12 +0000
commit23d9700f0737fdd547bda3e7d910300be4127120 (patch)
tree7d249ec21422e498dc5c1374b288889a7b931fcb
parent866e4196f4f50a41a1f176a17cc56609a13d4a10 (diff)
downloadforums-23d9700f0737fdd547bda3e7d910300be4127120.tar
forums-23d9700f0737fdd547bda3e7d910300be4127120.tar.gz
forums-23d9700f0737fdd547bda3e7d910300be4127120.tar.bz2
forums-23d9700f0737fdd547bda3e7d910300be4127120.tar.xz
forums-23d9700f0737fdd547bda3e7d910300be4127120.zip
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
-rw-r--r--phpBB/includes/session.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index c1741de0fd..c7d287181b 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -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)