Commit 24a54cd9 by Torkel Ödegaard

feat(units): refactoring #5404

parent a7a5f36b
...@@ -581,37 +581,10 @@ function($, _, moment) { ...@@ -581,37 +581,10 @@ function($, _, moment) {
} }
}; };
// Date and time
kbn.toDateTime = function(size, timeScale) {
var datetime;
if (timeScale === 's') {
datetime = moment.unix(size);
} else {
datetime = moment(size);
}
return datetime;
};
kbn.toDuration = function(size, timeScale) { kbn.toDuration = function(size, timeScale) {
return moment.duration(size, timeScale); return moment.duration(size, timeScale);
}; };
kbn.valueFormats.dtms = function(size) {
return kbn.toDateTime(size, 'ms').format('YYYY-MM-DD hh:mm:ss');
};
kbn.valueFormats.dts = function(size) {
return kbn.toDateTime(size, 's').format('YYYY-MM-DD hh:mm:ss');
};
kbn.valueFormats.dtfromnowms = function(size) {
return kbn.toDateTime(size, 'ms').fromNow(true);
};
kbn.valueFormats.dtfromnows = function(size) {
return kbn.toDateTime(size, 's').fromNow(true);
};
kbn.valueFormats.dtdurationms = function(size) { kbn.valueFormats.dtdurationms = function(size) {
return kbn.toDuration(size, 'ms').humanize(); return kbn.toDuration(size, 'ms').humanize();
}; };
...@@ -656,17 +629,8 @@ function($, _, moment) { ...@@ -656,17 +629,8 @@ function($, _, moment) {
{text: 'minutes (m)', value: 'm' }, {text: 'minutes (m)', value: 'm' },
{text: 'hours (h)', value: 'h' }, {text: 'hours (h)', value: 'h' },
{text: 'days (d)', value: 'd' }, {text: 'days (d)', value: 'd' },
] {text: 'duration (ms)', value: 'dtdurationms' },
}, {text: 'duration (s)', value: 'dtdurations' }
{
text: 'date and time',
submenu: [
{text: 'date and time (ms)', value: 'dtms'},
{text: 'date and time (s)', value: 'dts' },
{text: 'from now (ms)', value: 'dtfromnowms' },
{text: 'from now (s)', value: 'dtfromnows' },
{text: 'duration (ms)', value: 'dtdurationms' },
{text: 'duration (s)', value: 'dtdurations' }
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment