Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
added toNow filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ronky committed Jun 21, 2015
1 parent 859b76f commit 27e1ad3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions angular-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,32 @@
amTimeAgoFilter.$stateful = angularMomentConfig.statefulFilters;

return amTimeAgoFilter;
}])

/**
* @ngdoc filter
* @name angularMoment.filter:amTimeToNow
* @module angularMoment
* @function
*/
.filter('amTimeToNow', ['moment', 'amMoment', 'angularMomentConfig', function (moment, amMoment, angularMomentConfig) {
function amTimeToNowFilter(value, preprocess, suffix) {
if (typeof value === 'undefined' || value === null) {
return '';
}

value = amMoment.preprocessDate(value, preprocess);
var date = moment(value);
if (!date.isValid()) {
return '';
}

return amMoment.applyTimezone(date).toNow(suffix);
}

amTimeToNowFilter.$stateful = angularMomentConfig.statefulFilters;

return amTimeToNowFilter;
}]);
}

Expand Down

0 comments on commit 27e1ad3

Please sign in to comment.