Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oskarrough/ember-date-fns
Date helpers for Ember.js using date-fns
https://github.com/oskarrough/ember-date-fns
date-formatting ember
Last synced: 3 months ago
JSON representation
Date helpers for Ember.js using date-fns
- Host: GitHub
- URL: https://github.com/oskarrough/ember-date-fns
- Owner: oskarrough
- License: mit
- Created: 2017-01-11T00:37:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-18T16:53:43.000Z (almost 6 years ago)
- Last Synced: 2024-10-03T08:10:02.439Z (4 months ago)
- Topics: date-formatting, ember
- Language: JavaScript
- Homepage: https://ember-date-fns.surge.sh/
- Size: 263 KB
- Stars: 19
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ember date-fns
[![npm version](https://badge.fury.io/js/ember-date-fns.svg)](https://badge.fury.io/js/ember-date-fns)
[![CircleCI](https://circleci.com/gh/oskarrough/ember-date-fns.svg?style=svg)](https://circleci.com/gh/oskarrough/ember-date-fns)Lightweight date helpers for your ember-cli application thanks to [date-fns](https://date-fns.org/). If all you need is to format a date, Ember date-fns will help you.
If you are looking for more features, see [ember-moment](https://github.com/stefanpenner/ember-moment) instead.
## Installation
In your ember-cli project, run either
`ember install ember-date-fns`
or
`yarn add ember-date-fns`
or
`npm install --save ember-date-fns`
## Available helpers
All helpers map to the date-fns function of the same name.
+ [`date-format`](#date-format)
+ [`date-from-now`](#date-from-now)## Usage
### `date-format`
Uses [format](https://date-fns.org/docs/format) to format a date object, string or timestamp.
```hbs
{{date-format date "D. MMM YYYY"}}
```### `date-from-now`
Uses [distanceInWordsToNow](https://date-fns.org/docs/distanceInWordsToNow) to return "time ago". By default no suffix is added.
```hbs
{{date-from-now date addSuffix=true}}
```### Exposing additional date-fns
`date-fns` provides many functions for manipulating dates. In order to reduce bundle size only `date-fns/distance_in_words_to_now` and `date-fns/format` helpers are included by default. However you can import any functions anywhere in your application.
Example:
```javascript
// app/components/some-component.jsimport Ember from 'ember';
import endOfDay from 'date-fns/end_of_day';// Your component code here...
```