From a1457a0b8c0306c78d2ddd03fcc0c257c5cfd418 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 1 Jul 2022 11:20:02 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20schedule=20post=20da?= =?UTF-8?q?te=20picker=20sometimes=20not=20allowing=20"today"=20to=20be=20?= =?UTF-8?q?selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - with large site timezone UTC offsets it could happen that "today" in the site timezone is not selectable in the date picker when scheduling posts - the problem occurred because we were passing a minimum date to the date picker in UTC which was then converted to a local date using just the "YYYY-MM-DD" data but that would not always be correct because the UTC date could be "tomorrow" compared to the site timezone. Passing in the minimum date in the site timezone rather than UTC ensures the minimum date always matches "today" in the site timezone --- .../admin/app/components/editor/publish-options/publish-at.hbs | 2 +- ghost/admin/app/components/gh-date-time-picker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/editor/publish-options/publish-at.hbs b/ghost/admin/app/components/editor/publish-options/publish-at.hbs index 3951188f89..dbad95e48f 100644 --- a/ghost/admin/app/components/editor/publish-options/publish-at.hbs +++ b/ghost/admin/app/components/editor/publish-options/publish-at.hbs @@ -17,7 +17,7 @@ @time={{moment-format (moment-site-tz @publishOptions.scheduledAtUTC) "HH:mm"}} @setDate={{this.setDate}} @setTime={{this.setTime}} - @minDate={{@publishOptions.minScheduledAt}} + @minDate={{moment-site-tz @publishOptions.minScheduledAt}} @isActive={{@publishOptions.isScheduled}} @renderInPlace={{false}} /> diff --git a/ghost/admin/app/components/gh-date-time-picker.js b/ghost/admin/app/components/gh-date-time-picker.js index 1cfdbefaa3..93aa10fa97 100644 --- a/ghost/admin/app/components/gh-date-time-picker.js +++ b/ghost/admin/app/components/gh-date-time-picker.js @@ -119,7 +119,7 @@ export default class GhDateTimePicker extends Component { } this.set('_previousTime', this._time); - // unless min/max date is at midnight moment will diable that day + // unless min/max date is at midnight moment will disable that day if (minDate === 'now') { this.set('_minDate', moment(moment().format(DATE_FORMAT))); } else if (!isBlank(minDate)) { From fa92a62cd36b47855e0831439d9814b7ab6a61bc Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 1 Jul 2022 00:36:40 -0700 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20scheduled=20post=20d?= =?UTF-8?q?atepicker=20sometimes=20picking=20day=20before=20selected=20dat?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - in sites with a timezone that is negatively offset from UTC at certain times of day when the equivalent UTC date would be the next day, selecting a date when scheduling a post would select a day before the selected date - fixed the date adjustment when applying the selected date to properly take timezones into account --- .../components/editor/publish-options/publish-at.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/editor/publish-options/publish-at.js b/ghost/admin/app/components/editor/publish-options/publish-at.js index 969caca757..e59c2c8c75 100644 --- a/ghost/admin/app/components/editor/publish-options/publish-at.js +++ b/ghost/admin/app/components/editor/publish-options/publish-at.js @@ -8,11 +8,19 @@ export default class PublishAtOption extends Component { @action setDate(selectedDate) { - const newDate = moment(this.args.publishOptions.scheduledAtUTC); - const {years, months, date} = moment(selectedDate).toObject(); + const selectedMoment = moment(selectedDate); + const {years, months, date} = selectedMoment.toObject(); + // Create a new moment from existing scheduledAtUTC _in site timezone_. + // This ensures we're setting the date correctly because we don't need + // to account for the converted UTC date being yesterday/tomorrow. + const newDate = moment.tz( + this.args.publishOptions.scheduledAtUTC, + this.settings.get('timezone') + ); newDate.set({years, months, date}); + // converts back to UTC this.args.publishOptions.setScheduledAt(newDate); } From 862ace7945ff766366efbcc4e793a2418fea5714 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Tue, 5 Jul 2022 09:50:40 +0100 Subject: [PATCH 3/3] v5.2.4 --- ghost/admin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghost/admin/package.json b/ghost/admin/package.json index 99e6230bde..54c8aacda4 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -1,6 +1,6 @@ { "name": "ghost-admin", - "version": "5.2.3", + "version": "5.2.4", "description": "Ember.js admin client for Ghost", "author": "Ghost Foundation", "homepage": "http://ghost.org",