Use international standard date and time notation ...
... instead of depending on the locale. We hardcode date and time formats all over the place anyway. refs #6778
This commit is contained in:
parent
9edc4a129b
commit
14b24ff57d
|
@ -3,10 +3,8 @@
|
|||
|
||||
namespace Icinga\Date;
|
||||
|
||||
use IntlDateFormatter;
|
||||
|
||||
/**
|
||||
* ICU date formatting
|
||||
* Date formatting
|
||||
*/
|
||||
class DateFormatter
|
||||
{
|
||||
|
@ -57,8 +55,11 @@ class DateFormatter
|
|||
}
|
||||
if ($diff > 3600 * 24 * 3) {
|
||||
$type = static::DATE;
|
||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
|
||||
$formatted = $fmt->format($time);
|
||||
if (date('Y') === date('Y', $time)) {
|
||||
$formatted = date('M j', $time);
|
||||
} else {
|
||||
$formatted = date('Y-m', $time);
|
||||
}
|
||||
} else {
|
||||
$minutes = floor($diff / 60);
|
||||
if ($minutes < 60) {
|
||||
|
@ -67,9 +68,13 @@ class DateFormatter
|
|||
} else {
|
||||
$hours = floor($minutes / 60);
|
||||
if ($hours < 24) {
|
||||
$type = static::TIME;
|
||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::NONE, IntlDateFormatter::SHORT);
|
||||
$formatted = $fmt->format($time);
|
||||
if (date('d') === date('d', $time)) {
|
||||
$type = static::TIME;
|
||||
$formatted = date('H:i', $time);
|
||||
} else {
|
||||
$type = static::DATE;
|
||||
$formatted = date('M j H:i', $time);
|
||||
}
|
||||
} else {
|
||||
$type = static::RELATIVE;
|
||||
$formatted = sprintf('%dd %dh', floor($hours / 24), $hours % 24);
|
||||
|
@ -88,8 +93,7 @@ class DateFormatter
|
|||
*/
|
||||
public static function formatDate($date)
|
||||
{
|
||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
|
||||
return $fmt->format((float) $date);
|
||||
return date('Y-m-d', (float) $date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,8 +105,7 @@ class DateFormatter
|
|||
*/
|
||||
public static function formatDateTime($dateTime)
|
||||
{
|
||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
||||
return $fmt->format((float) $dateTime);
|
||||
return date('Y-m-d H:i:s', (float) $dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +117,7 @@ class DateFormatter
|
|||
*/
|
||||
public static function formatTime($time)
|
||||
{
|
||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::NONE, IntlDateFormatter::SHORT);
|
||||
return $fmt->format((float) $time);
|
||||
return date('H:i:s', (float) $time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue