-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter life to format torrent added time
- Loading branch information
1 parent
b5c15e8
commit 46353b4
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
}; | ||
} | ||
}()); |