mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
🐛 Fixed scheduled post datepicker sometimes picking day before selected date
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
This commit is contained in:
parent
cc570d23b0
commit
100dea6d98
1 changed files with 10 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue