Add extra checks to duration filter.

This commit is contained in:
Kegan Dougal 2014-11-14 15:34:19 +00:00
parent 5ebd004a10
commit d4f6d65e1d
2 changed files with 8 additions and 0 deletions

View File

@ -26,6 +26,9 @@ angular.module('matrixWebClient')
var h = parseInt(t / (60 * 60)) % 24;
var d = parseInt(t / (60 * 60 * 24));
if (t < 60) {
if (t < 0) {
return "0s";
}
return s + "s";
}
if (t < 60 * 60) {

View File

@ -285,6 +285,11 @@ describe('duration filter', function() {
var output = durationFilter(1000*60*60*2 + 1000*60*35);
expect(output).toEqual("2h");
});
it("should represent -ve numbers as '0s'", function() {
var output = durationFilter(-2000);
expect(output).toEqual("0s");
});
});
describe('orderMembersList filter', function() {