Rename "offset" to "blogTimezone"
refs https://github.com/TryGhost/Ghost/pull/6941#issuecomment-224553575 - `blogTimezone` and `timezone` better reflect their values (a string representing a timezone in the format `Europe/Dublin`) than `offset` which suggests a fixed value
This commit is contained in:
parent
bec486f542
commit
7c2e923074
@ -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));
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -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 = '';
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user