mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/13105] Do not display future dates 2+ days ahead as "tomorrow"
PHPBB3-13105
This commit is contained in:
parent
459c62b339
commit
e803efc6fc
1 changed files with 20 additions and 17 deletions
|
@ -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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue