summary refs log tree commit diff
path: root/webclient/app.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--webclient/app.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/webclient/app.js b/webclient/app.js
index 58d3942c65..3f4c5f30f8 100644
--- a/webclient/app.js
+++ b/webclient/app.js
@@ -94,6 +94,26 @@ matrixWebClient
             }
         };
     }])
+    .filter('duration', function() {
+        return function(time) {
+            if (!time) return;
+            var t = parseInt(time / 1000);
+            var s = t % 60;
+            var m = parseInt(t / 60) % 60;
+            var h = parseInt(t / (60 * 60)) % 24;
+            var d = parseInt(t / (60 * 60 * 24));
+            if (t < 60) {
+                return s + "s"
+            }
+            if (t < 60 * 60) {
+                return m + "m " + s + "s";
+            }
+            if (t < 24 * 60 * 60) {
+                return h + "h " + m + "m";
+            }
+            return d + "d " + h + "h";
+        }
+    })
     .filter('to_trusted', ['$sce', function($sce){
         return function(text) {
             return $sce.trustAsHtml(text);