1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

Merge pull request #2995 from nickvergessen/ticket/13105

[ticket/13105] Future relative dates are always displayed as "Tomorrow"

* nickvergessen/ticket/13105:
  [ticket/13105] Do not display future dates 2+ days ahead as "tomorrow"
  [ticket/13105] Add a test for relative dates
This commit is contained in:
Andreas Fischer
2014-09-25 21:52:53 +02:00
2 changed files with 90 additions and 19 deletions

View File

@@ -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']));
}
}
}
}