1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-datetime-input.js
Kevin Ansfield 5e9e3cd027 switch to ember-cli-moment-shim (#622)
no issue

- preparation for using `ember-pikaday` that utilizes `ember-cli-moment-shim`
- removes usage of `moment` global
- removes custom imports of `moment` and `moment-timezone` libraries
2017-04-05 19:45:35 +02:00

34 lines
1 KiB
JavaScript

import Component from 'ember-component';
import injectService from 'ember-service/inject';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import {formatDate} from 'ghost-admin/utils/date-formatting';
import {InvokeActionMixin} from 'ember-invoke-action';
import moment from 'moment';
export default Component.extend(InvokeActionMixin, {
tagName: 'span',
classNames: 'input-icon icon-calendar',
datetime: boundOneWay('value'),
inputClass: null,
inputId: null,
inputName: null,
settings: injectService(),
didReceiveAttrs() {
let datetime = this.get('datetime') || moment.utc();
let blogTimezone = this.get('settings.activeTimezone');
if (!this.get('update')) {
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`);
}
this.set('datetime', formatDate(datetime || moment.utc(), blogTimezone));
},
focusOut() {
let datetime = this.get('datetime');
this.invokeAction('update', datetime);
}
});