mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
9a68dca80e
refs https://github.com/TryGhost/Ghost/issues/8927 - removes usage of `Ember.testing` - removes usage of `Ember.uuid` - removes usage of `Ember.Debug.registerWarnHandler`
37 lines
734 B
JavaScript
37 lines
734 B
JavaScript
import Service from '@ember/service';
|
|
import config from 'ghost-admin/config/environment';
|
|
import moment from 'moment';
|
|
import {run} from '@ember/runloop';
|
|
|
|
const ONE_SECOND = 1000;
|
|
|
|
// Creates a clock service to run intervals.
|
|
|
|
export default Service.extend({
|
|
second: null,
|
|
minute: null,
|
|
hour: null,
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
this.tick();
|
|
},
|
|
|
|
tick() {
|
|
let now = moment().utc();
|
|
|
|
this.setProperties({
|
|
second: now.seconds(),
|
|
minute: now.minutes(),
|
|
hour: now.hours()
|
|
});
|
|
|
|
if (config.environment !== 'test') {
|
|
run.later(() => {
|
|
this.tick();
|
|
}, ONE_SECOND);
|
|
}
|
|
}
|
|
|
|
});
|