Skip to content

Commit

Permalink
Merge pull request #79 from Maximaximum/master
Browse files Browse the repository at this point in the history
Added support for momentjs objects
  • Loading branch information
astik committed Sep 5, 2016
2 parents f405566 + 5c2d07c commit 59ddac4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
7 changes: 5 additions & 2 deletions dist/angular-timeago-core.js
@@ -1,6 +1,6 @@
/**
* Angular directive/filter/service for formatting date so that it displays how long ago the given time was compared to now.
* @version v0.4.3 - 2016-06-15
* @version v0.4.3 - 2016-09-05
* @link https://github.com/yaru22/angular-timeago
* @author Brian Park <yaru22@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -60,7 +60,7 @@ angular.module('yaru22.angular-timeago').directive('timeAgo', ["timeAgo", "nowTi
var fromTime;

// Track changes to fromTime
scope.$watch('fromTime', function(value) {
scope.$watch('fromTime', function() {
fromTime = timeAgo.parse(scope.fromTime);
});

Expand All @@ -75,6 +75,7 @@ angular.module('yaru22.angular-timeago').directive('timeAgo', ["timeAgo", "nowTi
}]);

'use strict';
/*global moment */

angular.module('yaru22.angular-timeago').factory('timeAgo', ["$filter", "timeAgoSettings", function($filter, timeAgoSettings) {
var service = {};
Expand Down Expand Up @@ -157,6 +158,8 @@ angular.module('yaru22.angular-timeago').factory('timeAgo', ["$filter", "timeAgo
service.parse = function(input) {
if (input instanceof Date) {
return input;
} else if ((typeof moment !== 'undefined') && moment.isMoment(input)) {
return input.toDate();
} else if (angular.isNumber(input)) {
return new Date(input);
} else if (/^\d+$/.test(input)) {
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-timeago-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions dist/angular-timeago.js
@@ -1,6 +1,6 @@
/**
* Angular directive/filter/service for formatting date so that it displays how long ago the given time was compared to now.
* @version v0.4.3 - 2016-06-15
* @version v0.4.3 - 2016-09-05
* @link https://github.com/yaru22/angular-timeago
* @author Brian Park <yaru22@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -418,7 +418,7 @@ angular.module('yaru22.angular-timeago').directive('timeAgo', ["timeAgo", "nowTi
var fromTime;

// Track changes to fromTime
scope.$watch('fromTime', function(value) {
scope.$watch('fromTime', function() {
fromTime = timeAgo.parse(scope.fromTime);
});

Expand All @@ -433,6 +433,7 @@ angular.module('yaru22.angular-timeago').directive('timeAgo', ["timeAgo", "nowTi
}]);

'use strict';
/*global moment */

angular.module('yaru22.angular-timeago').factory('timeAgo', ["$filter", "timeAgoSettings", function($filter, timeAgoSettings) {
var service = {};
Expand Down Expand Up @@ -515,6 +516,8 @@ angular.module('yaru22.angular-timeago').factory('timeAgo', ["$filter", "timeAgo
service.parse = function(input) {
if (input instanceof Date) {
return input;
} else if ((typeof moment !== 'undefined') && moment.isMoment(input)) {
return input.toDate();
} else if (angular.isNumber(input)) {
return new Date(input);
} else if (/^\d+$/.test(input)) {
Expand Down

0 comments on commit 59ddac4

Please sign in to comment.