From e803efc6fcad0d49c515ead55eff9a66c6a35cca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Sep 2014 11:31:55 +0200 Subject: [PATCH] [ticket/13105] Do not display future dates 2+ days ahead as "tomorrow" PHPBB3-13105 --- phpBB/phpbb/datetime.php | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/phpBB/phpbb/datetime.php b/phpBB/phpbb/datetime.php index e674707883..63cdba90fd 100644 --- a/phpBB/phpbb/datetime.php +++ b/phpBB/phpbb/datetime.php @@ -91,25 +91,28 @@ class datetime extends \DateTime $midnight = $midnight->getTimestamp(); - $day = false; + if ($timestamp <= $midnight + 2 * 86400) + { + $day = false; - if ($timestamp > $midnight + 86400) - { - $day = 'TOMORROW'; - } - else if ($timestamp > $midnight) - { - $day = 'TODAY'; - } - else if ($timestamp > $midnight - 86400) - { - $day = 'YESTERDAY'; - } + if ($timestamp > $midnight + 86400) + { + $day = 'TOMORROW'; + } + else if ($timestamp > $midnight) + { + $day = 'TODAY'; + } + else if ($timestamp > $midnight - 86400) + { + $day = 'YESTERDAY'; + } - if ($day !== false) - { - // Format using the short formatting and finally swap out the relative token placeholder with the correct value - return str_replace(self::RELATIVE_WRAPPER . self::RELATIVE_WRAPPER, $this->user->lang['datetime'][$day], strtr(parent::format($format['format_short']), $format['lang'])); + if ($day !== false) + { + // Format using the short formatting and finally swap out the relative token placeholder with the correct value + return str_replace(self::RELATIVE_WRAPPER . self::RELATIVE_WRAPPER, $this->user->lang['datetime'][$day], strtr(parent::format($format['format_short']), $format['lang'])); + } } } }