Skip to content
Snippets Groups Projects
Commit 7c6ddb32 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fix comparison of dates in consultation creator, re #3350

Merge request studip/studip!3147
parent 198c2fea
No related branches found
No related tags found
No related merge requests found
......@@ -412,6 +412,25 @@ export default {
event.preventDefault();
}
},
compareDates(date0, date1, operator = '=', precision = 'day') {
const mapping = {
'<': 'isBefore',
'<=': 'isSameOrBefore',
'=': 'isSame',
'>=': 'isSameOrAfter',
'>': 'isAfter',
};
if (mapping[operator] === undefined) {
throw new Error(`Unsupported operator '${operator}'`);
}
const compareDate0 = moment(date0);
const compareDate1 = moment(date1);
const method = mapping[operator];
return compareDate0[method](compareDate1, precision);
},
validateInputs(event) {
const errors = [];
......@@ -419,7 +438,7 @@ export default {
errors.push(this.$gettext('Die Endzeit liegt vor der Startzeit!'));
}
if (this.interval > 0 && this.startDate > this.endDate) {
if (this.interval > 0 && this.compareDates(this.startDate, this.endDate, '>')) {
errors.push(this.$gettext('Das Enddatum liegt vor dem Startdatum!'));
}
......
......@@ -76,7 +76,7 @@ export default {
return this.convertInputToNativeDate(this.value).toISOString();
}
return this.convertInputToNativeDate(this.value).toLocaleDateString();
return this.convertInputToNativeDate(this.value).toLocaleDateString(String.locale);
}
},
methods: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment