Esempio n. 1
0
test('computed composition using locale and humanize', function(assert) {
  assert.expect(2);

  const subject = createSubject.call(this, {
    ms: 5000,
    duration: humanize(locale(duration('ms'), 'es'))
  });

  assert.equal(subject.get('duration'), 'unos segundos');
  subject.set('ms', 10800000);
  assert.equal(subject.get('duration'), '3 horas');
});
Esempio n. 2
0
import DS from 'ember-data';
import * as attrs from 'orders-app/models/attrs';
import momentComputed from 'ember-moment/computeds/moment';
import format from 'ember-moment/computeds/format';
import locale from 'ember-moment/computeds/locale';

export default DS.Model.extend({
  createdAt: attrs.firebaseTimestamp,
  title: DS.attr('string'),
  shortText: DS.attr('string'),
  longText: DS.attr('string'),
  smallImage: DS.attr('string'),
  largeImage: DS.attr('string'),
  createdOnFormatted: format(locale(momentComputed('createdAt'), 'moment.locale'), 'MMMM DD, YYYY')
});
Esempio n. 3
0
import Controller from '@ember/controller';
import duration from 'ember-moment/computeds/duration';
import format from 'ember-moment/computeds/format';
import fromNow from 'ember-moment/computeds/from-now';
import locale from 'ember-moment/computeds/locale';
import humanize from 'ember-moment/computeds/humanize';
import momentComputed from 'ember-moment/computeds/moment';

export default Controller.extend({
  moment: service(),
  actions: {
    changeLocale(locale) {
      get(this, 'moment').changeLocale(locale);
    },
    changeDefaultFormat(defaultFormat) {
      set(this, 'moment.defaultFormat', defaultFormat);
    }
  },
  emptyDate: null,
  numHours: 822,
  unixTimeStamp: 946684799,
  date: computed(() => new Date()),
  currentTime: computed(() => new Date()),
  inTwelveHours: computed(() => new Date(new Date().valueOf() + (12*60*60*1000))),
  lastHour: computed(() => new Date(new Date().valueOf() - (60*60*1000))),
  usIndependenceDay: computed(() => new Date(1776, 6, 4, 12, 0, 0)),
  computedDate: format(locale(momentComputed('date'), 'moment.locale')),
  computedOneHourAgo: fromNow(locale(momentComputed('lastHour'), 'moment.locale')),
  computedNumHours: humanize(locale(duration('numHours', 'hours'), 'moment.locale')),
});