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

This commit is contained in:
Joffrey JAFFEUX 2020-03-25 17:57:43 +01:00 committed by GitHub
parent c14f6d4ced
commit 105cc5505c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

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