time-ago-pipe
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "time-ago-pipe", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A simple Angular 2 pipe to change a date into a string of how long ago from it is from now", | ||
@@ -9,3 +9,3 @@ "main": "time-ago-pipe.js", | ||
"tsc": "tsc", | ||
"test": "mocha --reporter nyan" | ||
"test": "mocha --reporter spec" | ||
}, | ||
@@ -39,2 +39,3 @@ "repository": { | ||
"rxjs": "^5.0.0-beta.12", | ||
"sinon": "^1.17.6", | ||
"typescript": "^2.0.3", | ||
@@ -41,0 +42,0 @@ "zone.js": "^0.6.25" |
# time-ago-pipe | ||
[![Build Status](https://travis-ci.org/AndrewPoyntz/time-ago-pipe.svg?branch=master)](https://travis-ci.org/AndrewPoyntz/time-ago-pipe) [![npm](https://img.shields.io/npm/v/time-ago-pipe.svg?maxAge=2592000)]() [![npm](https://img.shields.io/npm/dt/time-ago-pipe.svg?maxAge=2592000)]() [![GitHub issues](https://img.shields.io/github/issues/AndrewPoyntz/time-ago-pipe.svg?maxAge=2592000?style=plastic)]() [![npm](https://img.shields.io/npm/l/time-ago-pipe.svg?maxAge=2592000)]() | ||
[![Build Status](https://travis-ci.org/AndrewPoyntz/time-ago-pipe.svg?branch=master)](https://travis-ci.org/AndrewPoyntz/time-ago-pipe) [![npm](https://img.shields.io/npm/v/time-ago-pipe.svg)]() [![npm](https://img.shields.io/npm/dt/time-ago-pipe.svg?maxAge=2592000)]() [![GitHub issues](https://img.shields.io/github/issues/AndrewPoyntz/time-ago-pipe.svg?maxAge=2592000?style=plastic)]() [![npm](https://img.shields.io/npm/l/time-ago-pipe.svg?maxAge=2592000?style=plastic)]() | ||
@@ -7,9 +7,57 @@ | ||
|Time Range|Output| | ||
|---|---| | ||
|0 - 45 seconds | a few seconds ago | | ||
|45 - 90 seconds | a minute ago | | ||
|90 seconds - 45 minutes | X minutes ago | | ||
|45 - 90 minutes | an hour ago | | ||
|90 minutes - 22 hours | X hours ago | | ||
|22 - 36 hours | a day ago | | ||
|36 hours - 25 days | X days ago | | ||
|25 - 45 days | a month ago | | ||
|45 - 345 days | X months ago | | ||
|345 - 545 days (1.5 years) | a year ago | | ||
|546 days+ | X years ago | | ||
##Installation | ||
```npm install time-ago-pipe --save``` | ||
## Usage | ||
In your component templates you can just do: | ||
``` | ||
<span>{{your_date | timeAgo}}</span> | ||
``` | ||
where "your_date" is something, which could be parsed by the standard Js Date() | ||
Import into your angular project, as you would for any other library. | ||
--- | ||
It can be imported into your angular project, as you would for any other library. | ||
Add "TimeAgoPipe" to your declarations in an @NgModule | ||
The d.ts files are included, so typings should be picked up automatically :+1: | ||
Then in your component templates: | ||
```<span>{{your_date | timeAgo}}</span>``` | ||
#### SystemJS | ||
in your system config file: | ||
``` | ||
map: { | ||
'time-ago-pipe':'node_modules/time-ago-pipe', | ||
etc | ||
} | ||
``` | ||
``` | ||
packages: { | ||
'time-ago-pipe': {main: 'time-ago-pipe.js'}, | ||
etc | ||
} | ||
``` | ||
Then in the @NgModule you want to use it in | ||
``` | ||
import {TimeAgoPipe} from 'time-ago-pipe | ||
``` | ||
& add "TimeAgoPipe" to your declarations | ||
``` | ||
@NgModule({ | ||
imports: [... etc ...], | ||
declarations: [AppComponent, ...etc..., TimeAgoPipe], | ||
bootstrap: [AppComponent] | ||
}) | ||
``` | ||
63
10487
11
7