Skip to content
Snippets Groups Projects
Commit d4f6d65e authored by Kegan Dougal's avatar Kegan Dougal
Browse files

Add extra checks to duration filter.

parent 5ebd004a
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,9 @@ angular.module('matrixWebClient') ...@@ -26,6 +26,9 @@ angular.module('matrixWebClient')
var h = parseInt(t / (60 * 60)) % 24; var h = parseInt(t / (60 * 60)) % 24;
var d = parseInt(t / (60 * 60 * 24)); var d = parseInt(t / (60 * 60 * 24));
if (t < 60) { if (t < 60) {
if (t < 0) {
return "0s";
}
return s + "s"; return s + "s";
} }
if (t < 60 * 60) { if (t < 60 * 60) {
......
...@@ -285,6 +285,11 @@ describe('duration filter', function() { ...@@ -285,6 +285,11 @@ describe('duration filter', function() {
var output = durationFilter(1000*60*60*2 + 1000*60*35); var output = durationFilter(1000*60*60*2 + 1000*60*35);
expect(output).toEqual("2h"); expect(output).toEqual("2h");
}); });
it("should represent -ve numbers as '0s'", function() {
var output = durationFilter(-2000);
expect(output).toEqual("0s");
});
}); });
describe('orderMembersList filter', function() { describe('orderMembersList filter', function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment