https://github.com/srph/angular-age-filter
An angular filter that converts date to age
https://github.com/srph/angular-age-filter
Last synced: 3 months ago
JSON representation
An angular filter that converts date to age
- Host: GitHub
- URL: https://github.com/srph/angular-age-filter
- Owner: srph
- License: mit
- Created: 2015-01-13T15:59:23.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-14T16:03:27.000Z (over 11 years ago)
- Last Synced: 2025-07-22T02:13:48.849Z (11 months ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angular-age-filter
[](https://travis-ci.org/srph/angular-age-filter)
[](https://badge.fury.io/bo/angular-srph-age-filter.svg)
[](http://twitter.com/_srph)
An angular filter that converts date to age for lazy people.
## Getting Started
Should work with AngularJS ```>=1.2.0```.
### Installation
**```angular-age-filter``` is available via [Bower]**
```bash
$ bower install angular-srph-age-filter
```
**Include the script to your HTML file**
```html
```
**Add the ```srph.age-filter``` module in your module's dependencies.**
```js
angular.module('myApp', ['srph.age-filter']);
```
### Usage
**Templates**
```html
{{ '11/23/1996' | age }}
{{ 848678400000 | age }}
```
**Controller, directives, etc..**
```js
app.controller('YoloController', function($scope, $filter) {
$scope.myDate = $filter('age')('11/23/1996');
$scope.hisDate = $filter('age')(848678400000);
})
```
**It also accepts a second parameter, testing the birthdate against a given time, such as:**
```html
{{ '11/23/1996' | age: '11/23/2001' }}
```
Outputs: ```5```
## Contribution
For features or fixes, I would suggest to submit an issue first before submitting a pull request. This avoids closed pull-requests; useless work.
```
========= ================
| issue | -> | pull-request |
========= ================
```
### Building
**Pre-requisites:**
1. ```karma-cli```
2. ```bower```
3. ```npm```
4. ```nodejs```
Start by forking this repository. Then run these commands to install the project's dependencies:
```bash
# root dir
$ npm install & bower install
```
Uglification / Testing:
```bash
# root dir
$ karma start # watches / runs the tests
$ npm run uglify # uglifies the source
```
### Coding Style
This was copy-pasted from [```ReactJS```'s contribution style guide](https://github.com/facebook/react/blob/master/CONTRIBUTING.md)
1. Use semicolons;
2. Commas last,
3. 2 spaces for indentation (no tabs)
4. Prefer ```'``` over ```"```
5. ```"use strict";```
6. 80 character line length
8. "Attractive"
9. Keep it simple, stupid
Do not forget to add tests!
## Acknowlegement
This isn't entirely my work; you might want to check this [Stack Overflow Answer](http://stackoverflow.com/questions/24883308/convert-birthday-to-age-in-angularjs) by [pixelbits](http://stackoverflow.com/users/3661630/pixelbits).
**angular-age-filter** © 2014+, Kier Borromeo (srph). Released under the [MIT](http://mit-license.org/) License.
> [srph.github.io](http://srph.github.io) ·
> GitHub [@srph](https://github.com/srph) ·
> Twitter [@_srph](https://twitter.com/_srph)
[MIT]: http://mit-license.org/