Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensures we have a date object in date-time-input (#9276)

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