Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Rename "offset" to "blogTimezone" #47

Merged
merged 1 commit into from Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/gh-datetime-input.js
Expand Up @@ -23,15 +23,15 @@ 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')) {
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`);
}

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));
});
},

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/post-settings-menu.js
Expand Up @@ -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 = '';

Expand Down
2 changes: 1 addition & 1 deletion app/services/time-zone.js
Expand Up @@ -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);
});
Expand Down
12 changes: 6 additions & 6 deletions app/utils/date-formatting.js
Expand Up @@ -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) : '');

This comment was marked as abuse.

}

export {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/services/time-zone-test.js
Expand Up @@ -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();
});
});
Expand Down