From e906a1979c5dc60749e521e7cd9b719c28eedc6d Mon Sep 17 00:00:00 2001 From: Anders Brander Date: Thu, 7 May 2015 22:33:32 +0200 Subject: [PATCH 1/2] Allow kbn.secondsToHms() to return result in milliseconds. --- public/app/components/kbn.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/app/components/kbn.js b/public/app/components/kbn.js index 652b7d6c923..973b28f40fd 100644 --- a/public/app/components/kbn.js +++ b/public/app/components/kbn.js @@ -81,11 +81,16 @@ function($, _, moment) { if(numminutes){ return numminutes + 'm'; } - var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60; + var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60); if(numseconds){ return numseconds + 's'; } - return 'less then a second'; //'just now' //or other string you like; + var nummilliseconds = Math.floor(seconds * 1000.0); + if(nummilliseconds){ + return nummilliseconds + 'ms'; + } + + return 'less then a millisecond'; //'just now' //or other string you like; }; kbn.to_percent = function(number,outof) { From d685644dee20bc927f3837d4228a541aac26f390 Mon Sep 17 00:00:00 2001 From: Anders Brander Date: Thu, 7 May 2015 22:48:44 +0200 Subject: [PATCH 2/2] Updated test to match e906a19 --- public/test/specs/kbn-format-specs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/test/specs/kbn-format-specs.js b/public/test/specs/kbn-format-specs.js index c7b9cf8cee1..d8a11c5a43c 100644 --- a/public/test/specs/kbn-format-specs.js +++ b/public/test/specs/kbn-format-specs.js @@ -63,7 +63,7 @@ define([ it('10m 1600 resolution', function() { var range = { from: kbn.parseDate('now-10m'), to: kbn.parseDate('now') }; var str = kbn.calculateInterval(range, 1600, null); - expect(str).to.be('0.1s'); + expect(str).to.be('100ms'); }); it('fixed user interval', function() {