Skip to content

Commit

Permalink
fix end date related to start date
Browse files Browse the repository at this point in the history
  • Loading branch information
mono424 committed Sep 27, 2023
1 parent 6003511 commit fbe9497
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@
:id="endId"
x-change-set-listen="changeSet.endDate"
x-on-change-set-update="$el._flatpickr.setDate(flatpickr.formatDate(changeSet.get().endDate, 'H:i'))"
x-init="flatpickr($el, {enableTime: true, noCalendar: true, altInput: true, altFormat: 'H:i', time_24hr: true, allowInput: true, onChange: (date) => changeSet.patch('end', flatpickr.formatDate(date[0], 'Z')) })"
x-init="flatpickr($el, {enableTime: true, noCalendar: true, altInput: true, altFormat: 'H:i', time_24hr: true, allowInput: true, onChange: (date) => {
const startDate = changeSet.get().startDate;
let val = date[0];
val.setDate(startDate.getDate());
val.setMonth(startDate.getMonth());
val.setYear(startDate.getFullYear());
changeSet.patch('end', flatpickr.formatDate(val, 'Z'))
}})"
/>
</label>
</template>
Expand Down
4 changes: 4 additions & 0 deletions web/ts/edit-course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export function lectureEditor(lecture: Lecture): AlpineComponent {
multiProperty(["start", "end"], (key: string, a: Lecture, b: Lecture): boolean | null => {
const dateA = new Date(a[key]);
const dateB = new Date(b[key]);
if (key == "end") {
console.log(dateA);
console.log(dateB);
}
return dateA.getTime() !== dateB.getTime();
}),
]);
Expand Down

0 comments on commit fbe9497

Please sign in to comment.