diff --git a/ghost/admin/app/components/gh-datetime-input.js b/ghost/admin/app/components/gh-datetime-input.js index fe800aefb6..675fec4a1b 100644 --- a/ghost/admin/app/components/gh-datetime-input.js +++ b/ghost/admin/app/components/gh-datetime-input.js @@ -23,7 +23,7 @@ export default Component.extend(TextInputMixin, { didReceiveAttrs() { let promises = { datetime: RSVP.resolve(this.get('datetime') || moment.utc()), - offset: RSVP.resolve(this.get('timeZone.offset')) + blogTimezone: RSVP.resolve(this.get('timeZone.blogTimezone')) }; if (!this.get('update')) { @@ -31,7 +31,7 @@ export default Component.extend(TextInputMixin, { } RSVP.hash(promises).then((hash) => { - this.set('datetime', formatDate(hash.datetime || moment.utc(), hash.offset)); + this.set('datetime', formatDate(hash.datetime || moment.utc(), hash.blogTimezone)); }); }, diff --git a/ghost/admin/app/controllers/post-settings-menu.js b/ghost/admin/app/controllers/post-settings-menu.js index 0b4b1ea85e..1fb6f9ec5e 100644 --- a/ghost/admin/app/controllers/post-settings-menu.js +++ b/ghost/admin/app/controllers/post-settings-menu.js @@ -297,8 +297,8 @@ export default Controller.extend(SettingsMenuMixin, { } return; } - this.get('timeZone.offset').then((offset) => { - let newPublishedAt = parseDateString(userInput, offset); + this.get('timeZone.blogTimezone').then((blogTimezone) => { + let newPublishedAt = parseDateString(userInput, blogTimezone); let publishedAt = moment.utc(this.get('model.publishedAt')); let errMessage = ''; diff --git a/ghost/admin/app/services/time-zone.js b/ghost/admin/app/services/time-zone.js index aeafca9038..1c2efd6d2d 100644 --- a/ghost/admin/app/services/time-zone.js +++ b/ghost/admin/app/services/time-zone.js @@ -19,7 +19,7 @@ export default Service.extend({ return store.queryRecord('setting', {type: 'blog,theme,private'}); }), - offset: computed('_settings.activeTimezone', function () { + blogTimezone: computed('_settings.activeTimezone', function () { return this.get('_settings').then((settings) => { return this._parseTimezones(settings); }); diff --git a/ghost/admin/app/utils/date-formatting.js b/ghost/admin/app/utils/date-formatting.js index 8bc36ffb3d..342fb430b2 100644 --- a/ghost/admin/app/utils/date-formatting.js +++ b/ghost/admin/app/utils/date-formatting.js @@ -24,18 +24,18 @@ function verifyTimeStamp(dateString) { } // Parses a string to a Moment -function parseDateString(value, offset) { - // We need the offset here, otherwise the date will be parsed +function parseDateString(value, timezone) { + // We need the timezone here, otherwise the date will be parsed // in UTC timezone - moment.tz.setDefault(offset); + moment.tz.setDefault(timezone); return value ? moment(verifyTimeStamp(value), parseDateFormats, true) : undefined; } // Formats a Date or Moment -function formatDate(value, offset) { - // we output the date adjusted by the offset of the timezone set in the blog setting - return verifyTimeStamp(value ? moment(value).tz(offset).format(displayDateFormat) : ''); +function formatDate(value, timezone) { + // we output the date adjusted to the blog timezone selected in settings + return verifyTimeStamp(value ? moment(value).tz(timezone).format(displayDateFormat) : ''); } export { diff --git a/ghost/admin/tests/integration/services/time-zone-test.js b/ghost/admin/tests/integration/services/time-zone-test.js index 33f2028762..e7e644a15a 100644 --- a/ghost/admin/tests/integration/services/time-zone-test.js +++ b/ghost/admin/tests/integration/services/time-zone-test.js @@ -38,13 +38,13 @@ describeModule( server.shutdown(); }); - it('should return a timezone offset', function (done) { + it('should return the blogs timezone', function (done) { let service = this.subject(); settingsStub(server); - service.get('offset').then(function (offset) { - expect(offset).to.equal('Africa/Cairo'); + service.get('blogTimezone').then(function (blogTimezone) { + expect(blogTimezone).to.equal('Africa/Cairo'); done(); }); });