Skip to content

Commit

Permalink
add filter life to format torrent added time
Browse files Browse the repository at this point in the history
  • Loading branch information
taobataoma committed Apr 5, 2017
1 parent b5c15e8 commit 46353b4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions modules/core/client/filter/life.client.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(function () {
'use strict';

// Focus the element on page load
// Unless the user is on a small device, because this could obscure the page with a keyboard

angular.module('core')
.filter('life', life);

life.$inject = ['moment'];

function life(moment) {
return function (created) {
var d = moment().diff(moment(created), 'days');
var h = moment().diff(moment(created), 'hours');
var m = moment().diff(moment(created), 'minutes');

if (d > 0) {
h = h - d * 24;
return d + 'D' + h + 'H';
} else {
m = m - h + 60;
return h + 'H' + m + 'M';
}
};
}
}());

0 comments on commit 46353b4

Please sign in to comment.