Skip to content

Commit

Permalink
Updating README
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmit committed Jan 23, 2016
1 parent 52dcc4a commit 126e945
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ It's advisable to run `ember g ember-moment` between upgrades as dependencies ma

### Computed Property Macros

Ships with the following computed property macros: `duration`, `humanize`, `locale`, `format`, `moment`, `toNow`, `fromNow`. They can be used individually or composed together.
Ships with the following computed property macros: `duration`, `humanize`, `locale`, `tz`, `format`, `calendar`, `moment`, `toNow`, `fromNow`. They can be used individually or composed together.

[Full API Documentation](https://github.com/stefanpenner/ember-moment/wiki/Computed-Property-Macros)

Expand All @@ -56,11 +56,12 @@ Locale takes a moment object and apply a locale to that instance
import momentComputed from 'ember-moment/computeds/moment';
import format from 'ember-moment/computeds/format';
import locale from 'ember-moment/computeds/locale';
import tz from 'ember-moment/computeds/tz';

export default Ember.Component.extend({
moment: Ember.inject.service(),
createdOn: new Date('01/02/2016'),
createdOnFormatted: format(locale(momentComputed('createdOn'), 'moment.locale'), 'MMMM DD, YYYY')
createdOnFormatted: format(tz(locale(momentComputed('createdOn'), 'moment.locale'), 'America/New_York'), 'MMMM DD, YYYY')
});
```

Expand Down
2 changes: 1 addition & 1 deletion addon/computeds/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default computedFactory(function calendarComputed(params) {
throw new TypeError('ember-moment: Invalid Number of arguments, at most 2');
}

const [date, referenceTime] = params;
const [ date, referenceTime ] = params;

return moment(date).calendar(referenceTime);
});
8 changes: 4 additions & 4 deletions addon/computeds/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import moment from 'moment';

import computedFactory from './-base';

export default computedFactory(function localeComputed([value, locale]) {
if (moment.isMoment(value)) {
value = moment(value);
export default computedFactory(function localeComputed([date, locale]) {
if (!moment.isDuration(date)) {
date = moment(date);
}

return value.locale(locale);
return date.locale(locale);
});
8 changes: 2 additions & 6 deletions addon/computeds/tz.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import moment from 'moment';

import computedFactory from './-base';

export default computedFactory(function tzComputed([value, tz]) {
if (moment.isMoment(value)) {
value = moment(value);
}

return value.tz(tz);
export default computedFactory(function tzComputed([date, tz]) {
return moment(date).tz(tz);
});

0 comments on commit 126e945

Please sign in to comment.