angular-timeago
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -27,3 +27,3 @@ { | ||
}, | ||
"version": "0.1.5" | ||
"version": "0.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.1.5 - 2014-12-10 | ||
* @version v0.1.6 - 2014-12-18 | ||
* @link https://github.com/yaru22/angular-timeago | ||
@@ -5,0 +5,0 @@ * @author Brian Park <yaru22@gmail.com> |
@@ -8,3 +8,3 @@ { | ||
"description": "Angular directive/filter/service for formatting date so that it displays how long ago the given time was compared to now.", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"license": "MIT", | ||
@@ -11,0 +11,0 @@ "homepage": "https://github.com/yaru22/angular-timeago", |
@@ -10,2 +10,29 @@ # angular-timeago [![Analytics](https://ga-beacon.appspot.com/UA-2694988-7/angular-timeago/readme?pixel)](https://github.com/yaru22/angular-timeago) | ||
## Usage | ||
**Filter** | ||
``` | ||
{{myDate | timeAgo}} | ||
``` | ||
Displays time ago since `myDate`. `myDate` can be time in **milliseconds since January 1st 1970** (see [MDN Date.prototype.getTime](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)) or an **ISO 8601** string (see [MDN Date.prototype.toISOString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)) | ||
**Language support** | ||
angular-timeago currently supports: `en_US`, `de_DE`, `he_IL`. If you want more languages: feel free to contribute! | ||
The language is determined by the string in `document.documentElement.lang` which you can set in your HTML markup: | ||
``` | ||
<html lang="en_US"></html> | ||
``` | ||
Or directly in JS: | ||
``` | ||
window.document.documentElement.lang = 'en_US'; | ||
``` | ||
You can also add additional or alter existing languages at runtime by extending the service: | ||
``` | ||
timeAgo.settings.strings.en_US = { | ||
// appropriate keys here | ||
}; | ||
``` | ||
For more details refer to the [source code](https://github.com/yaru22/angular-timeago/blob/master/src/timeAgo.js#L47). | ||
## Testing | ||
@@ -22,2 +49,1 @@ | ||
grunt test | ||
``` |
@@ -6,3 +6,3 @@ /* global angular */ | ||
angular.module('yaru22.angular-timeago', [ | ||
]).directive('timeAgo', function (timeAgo, nowTime) { | ||
]).directive('timeAgo', ['timeAgo', 'nowTime', function (timeAgo, nowTime) { | ||
return { | ||
@@ -26,3 +26,3 @@ restrict: 'EA', | ||
}; | ||
}).factory('nowTime', function ($window, $rootScope) { | ||
}]).factory('nowTime', ['$window', '$rootScope', function ($window, $rootScope) { | ||
var nowTime = Date.now(); | ||
@@ -41,3 +41,3 @@ var updateTime = function() { | ||
}; | ||
}).factory('timeAgo', function () { | ||
}]).factory('timeAgo', function () { | ||
var service = {}; | ||
@@ -167,3 +167,3 @@ | ||
return service; | ||
}).filter('timeAgo', function (nowTime, timeAgo) { | ||
}).filter('timeAgo', ['nowTime', 'timeAgo', function (nowTime, timeAgo) { | ||
return function (value) { | ||
@@ -174,2 +174,2 @@ var fromTime = timeAgo.parse(value); | ||
}; | ||
}); | ||
}]); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
755503
48