Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme fix #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# 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)](https://www.npmjs.com/package/time-ago-pipe) [![npm](https://img.shields.io/npm/dt/time-ago-pipe.svg?maxAge=25920)](https://www.npmjs.com/package/time-ago-pipe) [![GitHub issues](https://img.shields.io/github/issues/AndrewPoyntz/time-ago-pipe.svg?maxAge=25920?style=plastic)](https://github.com/AndrewPoyntz/time-ago-pipe/issues) [![npm](https://img.shields.io/npm/l/time-ago-pipe.svg?maxAge=25920?style=plastic)](https://github.com/AndrewPoyntz/time-ago-pipe/blob/master/LICENSE)


A really simple, lightweight Angular pipe for converting a date string into a time ago
A really simple, lightweight [Angular](https://angular.io/) pipe for converting a _date string_ into a _time ago_.

|Time Range|Output|
|---|---|
Expand All @@ -24,23 +23,29 @@ A really simple, lightweight Angular pipe for converting a date string into a ti
## Usage
It can be imported into your angular project, as you would for any other library.

In the @NgModule you want to use it in
```
import {TimeAgoPipe} from 'time-ago-pipe';
```
add "TimeAgoPipe" to your declarations
```
In the **@NgModule** you want to use it in:

~~~~
import { TimeAgoPipe } from 'time-ago-pipe';
~~~~

add **TimeAgoPipe** to your declarations:

~~~~
@NgModule({
imports: [... etc ...],
declarations: [..., TimeAgoPipe, ... ]
imports: [... etc ...],
declarations: [..., TimeAgoPipe, ... ]
})
```
~~~~

---

In your component templates you can just do:
```
<span>{{your_date | timeAgo}}</span>
```
where "your_date" is a local date string, which could be parsed by the standard Js Date()

If this value is null or not parsable as a date, then the pipe will display nothing
~~~~
<span>{{ your_date | timeAgo }}</span>
~~~~

where **your_date** is a local _date_ string, which could be parsed by the standard JavaScript [Date()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)

If `this` value is _null_ or not parsable as a [Date()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date), then the pipe will display nothing.