Only restrict event time picker times when same day

Otherwise it was getting tricky to change time for a different date

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-07-07 09:21:00 +02:00
parent 5fe829ae76
commit 315353ea83
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -34,8 +34,8 @@
placeholder="Type or select a time..."
icon="clock"
v-model="dateWithTime"
:min-time="minDatetime"
:max-time="maxDatetime"
:min-time="minTime"
:max-time="maxTime"
size="is-small"
inline
>
@ -100,6 +100,28 @@ export default class DateTimePicker extends Vue {
*/
this.$emit("input", this.dateWithTime);
}
get minTime(): Date | null {
if (this.minDatetime && this.datesAreOnSameDay(this.dateWithTime, this.minDatetime)) {
return this.minDatetime;
}
return null;
}
get maxTime(): Date | null {
if (this.maxDatetime && this.datesAreOnSameDay(this.dateWithTime, this.maxDatetime)) {
return this.maxDatetime;
}
return null;
}
private datesAreOnSameDay(first: Date, second: Date): boolean {
return (
first.getFullYear() === second.getFullYear() &&
first.getMonth() === second.getMonth() &&
first.getDate() === second.getDate()
);
}
}
</script>