ember-cli-dates
v1.1.3
Published
Ember date helpers with locale support.
Downloads
30
Maintainers
Readme
ember-cli-dates
Ember date helpers with locale support.
This addon includes time-ago-in-words
, time-ahead-in-words
, time-delta-in-words
,
time-format
, day-of-the-week
, date-and-time
, month-and-day
, month-and-year
.
It uses moment.js.
Installation
ember install:addon ember-cli-dates
Usage
Now, in your views/templates/components:
Time Deltas
Time Ago in Words
{{time-ago-in-words createdAt}} {{! => twelve days ago}}
Time Ahead in Words
{{time-ahead-in-words toBePublishedAt}} {{! => in 4 hours}}
Time Delta in Words
{{time-delta-in-words completedAt}} {{! => 7 minutes ago}}
Month and Day
{{month-and-day completedAt}} {{! => Jan 1st}}
{{month-and-day completedAt}} {{! => jan 1º}}
Month and Year
{{month-and-year completedAt 'pt-br'}} {{! => Jan 2015}}
Date and Time
{{date-and-time publishedAt}} {{! January 1, 2014 12:00 AM}}
{{date-and-time publishedAt 'pt-br'}} {{! 1 de janeiro de 2014 às 00:00}}
Custom Format
{{time-format updatedAt 'l'}} {{! => 10/9/2014}}
Day of the Week
{{day-of-the-week someDate}} {{! => Friday}}
Locale Support
In order to add locale support, you need to import the locale file in your app's Brocfile.js
:
app.import(app.bowerDirectory + '/moment/locale/pt-br.js');
You then have the ability to specify any imported locale with:
{{time-format createdAt 'LLLL' 'pt-br'}}
{{time-ahead-in-words nextHour 'pt-br'}}
License
MIT
Contributing
- Fork it
- npm install
- bower install
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Crafted with <3 by John Otander(@4lpine).