Utils: add duration format/render
from pve-manager Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
6d812e6d8b
commit
e9fc81fabe
27
Utils.js
27
Utils.js
@ -145,6 +145,26 @@ Ext.define('Proxmox.Utils', { utilities: {
|
||||
return Ext.Date.format(date, "Y-m-d");
|
||||
},
|
||||
|
||||
format_duration_short: function(ut) {
|
||||
|
||||
if (ut < 60) {
|
||||
return ut.toFixed(1) + 's';
|
||||
}
|
||||
|
||||
if (ut < 3600) {
|
||||
var mins = ut / 60;
|
||||
return mins.toFixed(1) + 'm';
|
||||
}
|
||||
|
||||
if (ut < 86400) {
|
||||
var hours = ut / 3600;
|
||||
return hours.toFixed(1) + 'h';
|
||||
}
|
||||
|
||||
var days = ut / 86400;
|
||||
return days.toFixed(1) + 'd';
|
||||
},
|
||||
|
||||
format_duration_long: function(ut) {
|
||||
|
||||
var days = Math.floor(ut / 86400);
|
||||
@ -643,6 +663,13 @@ Ext.define('Proxmox.Utils', { utilities: {
|
||||
return task;
|
||||
},
|
||||
|
||||
render_duration: function(value) {
|
||||
if (value === undefined) {
|
||||
return '-';
|
||||
}
|
||||
return Proxmox.Utils.format_duration_short(value);
|
||||
},
|
||||
|
||||
render_timestamp: function(value, metaData, record, rowIndex, colIndex, store) {
|
||||
var servertime = new Date(value * 1000);
|
||||
return Ext.Date.format(servertime, 'Y-m-d H:i:s');
|
||||
|
Loading…
Reference in New Issue
Block a user