mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-08 22:44:24 +02:00
Let DateFormatter format dates like Format::smartTimeDiff()
Date diffs which are bigger than 3 days are now displayed w/o time again. refs #6778
This commit is contained in:
parent
2440308699
commit
ae1962af27
@ -107,8 +107,8 @@ class DateFormatter
|
|||||||
$invert = true;
|
$invert = true;
|
||||||
}
|
}
|
||||||
if ($diff > 3600 * 24 * 3) {
|
if ($diff > 3600 * 24 * 3) {
|
||||||
$type = static::DATETIME;
|
$type = static::DATE;
|
||||||
$fmt = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
$fmt = new IntlDateFormatter(null, IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
|
||||||
$formatted = $fmt->format($time);
|
$formatted = $fmt->format($time);
|
||||||
} else {
|
} else {
|
||||||
$minutes = floor($diff / 60);
|
$minutes = floor($diff / 60);
|
||||||
@ -137,11 +137,14 @@ class DateFormatter
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case static::TIME:
|
case static::TIME:
|
||||||
$formatted = sprintf(t('at %s', 'An event that happened at the given time'), $formatted);
|
$formatted = sprintf(t('at %s', 'An event happened at the given time'), $formatted);
|
||||||
break;
|
break;
|
||||||
|
case static::DATE:
|
||||||
|
// Move to next case
|
||||||
case static::DATETIME:
|
case static::DATETIME:
|
||||||
|
// TODO(el): Use own format string for date?
|
||||||
$formatted = sprintf(
|
$formatted = sprintf(
|
||||||
t('on %s', 'An event that happened at the given date and time'),
|
t('on %s', 'An event happened on the given date or date and time'),
|
||||||
$formatted
|
$formatted
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -158,8 +161,14 @@ class DateFormatter
|
|||||||
case static::TIME:
|
case static::TIME:
|
||||||
$formatted = sprintf(t('at %s', 'An event will happen at the given time'), $formatted);
|
$formatted = sprintf(t('at %s', 'An event will happen at the given time'), $formatted);
|
||||||
break;
|
break;
|
||||||
|
case static::DATE:
|
||||||
|
// Move to next case
|
||||||
case static::DATETIME:
|
case static::DATETIME:
|
||||||
$formatted = sprintf(t('on %s', 'An event will happen on the given date and time'), $formatted);
|
// TODO(el): Use own format string for date?
|
||||||
|
$formatted = sprintf(
|
||||||
|
t('on %s', 'An event will happen on the given date or date and time'),
|
||||||
|
$formatted
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -173,9 +182,12 @@ class DateFormatter
|
|||||||
break;
|
break;
|
||||||
case static::TIME:
|
case static::TIME:
|
||||||
// Move to next case
|
// Move to next case
|
||||||
|
case static::DATE:
|
||||||
|
// Move to next case
|
||||||
case static::DATETIME:
|
case static::DATETIME:
|
||||||
|
// TODO(el): Use own format strings for time and date?
|
||||||
$formatted = sprintf(
|
$formatted = sprintf(
|
||||||
t('since %s', 'A status is lasting since the given date and time'),
|
t('since %s', 'A status is lasting since the given time, date or date and time'),
|
||||||
$formatted
|
$formatted
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user