mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Unify time interval formatting (#14733)
* Unify time interval formatting Use carbon for formatting, it supports locales. * fix style * remove baseline exceptions * fixes found by lint
This commit is contained in:
@@ -5,7 +5,6 @@ use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\Clean;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\Time;
|
||||
|
||||
echo "<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
@@ -104,17 +103,17 @@ if ($device['sysContact']) {
|
||||
|
||||
if (! empty($device['inserted']) && preg_match('/^0/', $device['inserted']) == 0) {
|
||||
$inserted_text = 'Device Added';
|
||||
$inserted = (Time::formatInterval(time() - strtotime($device['inserted'])) . ' ago');
|
||||
$inserted = (\LibreNMS\Util\Time::formatInterval(-(time() - strtotime($device['inserted']))));
|
||||
echo "<div class='row'><div class='col-sm-4'>$inserted_text</div><div class='col-sm-8' title='$inserted_text on " . $device['inserted'] . "'>$inserted</div></div>";
|
||||
}
|
||||
|
||||
if (! empty($device['last_discovered'])) {
|
||||
$last_discovered_text = 'Last Discovered';
|
||||
$last_discovered = (empty($device['last_discovered']) ? 'Never' : Time::formatInterval(time() - strtotime($device['last_discovered'])) . ' ago');
|
||||
$last_discovered = (empty($device['last_discovered']) ? 'Never' : \LibreNMS\Util\Time::formatInterval(-(time() - strtotime($device['last_discovered']))));
|
||||
echo "<div class='row'><div class='col-sm-4'>$last_discovered_text</div><div class='col-sm-8' title='$last_discovered_text at " . $device['last_discovered'] . "'>$last_discovered</div></div>";
|
||||
}
|
||||
|
||||
$uptime = (Time::formatInterval($device['status'] ? $device['uptime'] : time() - strtotime($device['last_polled'])));
|
||||
$uptime = (\LibreNMS\Util\Time::formatInterval($device['status'] ? $device['uptime'] : time() - strtotime($device['last_polled'])));
|
||||
$uptime_text = ($device['status'] ? 'Uptime' : 'Downtime');
|
||||
|
||||
if ($uptime) {
|
||||
|
@@ -13,7 +13,7 @@ $colour_area = '8B8BEB44';
|
||||
|
||||
$colour_area_max = 'cc9999';
|
||||
|
||||
$line_text = \LibreNMS\Util\Time::humanTime($vars['duration']);
|
||||
$line_text = \LibreNMS\Util\Time::formatInterval($vars['duration'], parts: 1);
|
||||
|
||||
$graph_title .= '::' . $line_text;
|
||||
|
||||
|
@@ -16,7 +16,7 @@ foreach ($duration_list as $duration) {
|
||||
$graph_array['type'] = 'device_' . $graph_type;
|
||||
$graph_array['duration'] = $duration['duration'];
|
||||
|
||||
$human_duration = \LibreNMS\Util\Time::humanTime($duration['duration']);
|
||||
$human_duration = \LibreNMS\Util\Time::formatInterval($duration['duration'], parts: 1);
|
||||
$graph_title = DeviceCache::get($device['device_id'])->displayName() . ' - ' . $human_duration;
|
||||
|
||||
echo "<div class='panel panel-default'>
|
||||
|
Reference in New Issue
Block a user