Kaynağa Gözat

Allow kbn.secondsToHms() to return result in milliseconds.

Anders Brander 10 yıl önce
ebeveyn
işleme
e906a1979c
1 değiştirilmiş dosya ile 7 ekleme ve 2 silme
  1. 7 2
      public/app/components/kbn.js

+ 7 - 2
public/app/components/kbn.js

@@ -81,11 +81,16 @@ function($, _, moment) {
     if(numminutes){
     if(numminutes){
       return numminutes + 'm';
       return numminutes + 'm';
     }
     }
-    var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
+    var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60);
     if(numseconds){
     if(numseconds){
       return numseconds + 's';
       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) {
   kbn.to_percent = function(number,outof) {