mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
9487ff9bae
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
40 lines
727 B
JavaScript
40 lines
727 B
JavaScript
import Ember from 'ember';
|
|
import Service from 'ember-service';
|
|
import run from 'ember-runloop';
|
|
import moment from 'moment';
|
|
|
|
// ember-cli-shims doesn't export Ember.testing
|
|
const {testing} = Ember;
|
|
|
|
const ONE_SECOND = 1000;
|
|
|
|
// Creates a clock service to run intervals.
|
|
|
|
export default Service.extend({
|
|
second: null,
|
|
minute: null,
|
|
hour: null,
|
|
|
|
init() {
|
|
this.tick();
|
|
},
|
|
|
|
tick() {
|
|
let now = moment().utc();
|
|
|
|
this.setProperties({
|
|
second: now.seconds(),
|
|
minute: now.minutes(),
|
|
hour: now.hours()
|
|
});
|
|
|
|
if (!testing) {
|
|
run.later(() => {
|
|
this.tick();
|
|
}, ONE_SECOND);
|
|
}
|
|
|
|
}
|
|
|
|
});
|