JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q21463F
  • License MIT

A really simple, lightweight Angular pipe for converting a date string into a time ago

Package Exports

  • persian-time-ago-pipe

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (persian-time-ago-pipe) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

persian-time-ago-pipe

Build Status npm npm GitHub issues npm

A really simple, lightweight Angular pipe for converting a date string into a time ago

Time Range Output
0 - 45 seconds چند ثانیه پیش
45 - 90 seconds دقیقه ای پیش
90 seconds - 45 minutes X دقیقه پیش
45 - 90 minutes ساعتی پیش
90 minutes - 22 hours X ساعت پیش
22 - 36 hours روزی پیش
36 hours - 25 days X روز پیش
25 - 45 days a یک ماه پیش
45 - 345 days X ماه پیش
345 - 545 days (1.5 years) یک سال پیش
546 days+ X سال پیش

Installation

npm install persian-time-ago-pipe --save

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 {PersianTimeAgoPipe} from 'persian-time-ago-pipe'; add "PersianTimeAgoPipe" to your declarations @NgModule({ imports: [... etc ...], declarations: [..., PersianTimeAgoPipe, ... ] })

In your component templates you can just do:

<span>{{your_date | persianTimeAgo}}</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