From 6c2a8a7cc45e1a78f34f88f6d4de37b5c4b288df Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 20 Apr 2021 09:16:06 -0600 Subject: [PATCH] Convert date.js to a native class Updating this to Octane idioms allows us to remove one more bit of Ember Classic code in the ecosystem! --- addon-test-support/date.js | 18 +++++++++--------- addon/services/date.js | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addon-test-support/date.js b/addon-test-support/date.js index 41b2d46..a501090 100644 --- a/addon-test-support/date.js +++ b/addon-test-support/date.js @@ -6,28 +6,28 @@ import DateService from "ember-date-service/services/date"; * Extends the provided internal DateService, allowing you to override * Date.now() and Date.UTC() without modifying the native Date object. */ -export default DateService.extend({ - init() { - this._super(...arguments); +export default class FakeDateService extends DateService { + constructor() { + super(...arguments); this._now = null; - }, + } now() { if (this._now) { return this._now; } - return this._super(...arguments); - }, + return super(...arguments); + } setNow(date = Date.now()) { this._now = date instanceof Date ? date.getTime() : date; return this._now; - }, + } reset() { this._now = null; - }, -}); + } +} diff --git a/addon/services/date.js b/addon/services/date.js index 3a10422..5609918 100644 --- a/addon/services/date.js +++ b/addon/services/date.js @@ -10,16 +10,16 @@ import Service from '@ember/service'; * which allows you to override dates with static values without having to * modify the native Date object. */ -export default Service.extend({ +export default class DateService extends Service { now() { return Date.now(); - }, + } UTC(...args) { return new Date(Date.UTC(...args)); - }, + } parse(dateString) { return Date.parse(dateString); - }, -}); + } +}