From 105cc5505c4efe4edd43b6fe409667f34db53a43 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 25 Mar 2020 17:57:43 +0100 Subject: [PATCH] FIX: ensures we have a date object in date-time-input (#9276) --- .../discourse/components/date-time-input.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/components/date-time-input.js b/app/assets/javascripts/discourse/components/date-time-input.js index 392dc5dac0f..81a7a10b927 100644 --- a/app/assets/javascripts/discourse/components/date-time-input.js +++ b/app/assets/javascripts/discourse/components/date-time-input.js @@ -7,19 +7,20 @@ export default Component.extend({ showTime: true, _hours: computed("date", function() { - return this.date && this.showTime ? this.date.getHours() : null; + return this.date && this.showTime ? new Date(this.date).getHours() : null; }), _minutes: computed("date", function() { - return this.date && this.showTime ? this.date.getMinutes() : null; + return this.date && this.showTime ? new Date(this.date).getMinutes() : null; }), actions: { onChangeTime(time) { if (this.onChange) { - const year = this.date.getFullYear(); - const month = this.date.getMonth(); - const day = this.date.getDate(); + const date = new Date(this.date); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); this.onChange(new Date(year, month, day, time.hours, time.minutes)); } },