Skip to content

Commit

Permalink
fix(dav): Allow single-day out of office
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Nov 29, 2023
1 parent e589232 commit 84cfbe6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/Controller/AvailabilitySettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function updateAbsence(

$parsedFirstDay = new DateTimeImmutable($firstDay);
$parsedLastDay = new DateTimeImmutable($lastDay);
if ($parsedFirstDay->getTimestamp() >= $parsedLastDay->getTimestamp()) {
if ($parsedFirstDay->getTimestamp() > $parsedLastDay->getTimestamp()) {
throw new \Exception('First day is on or after last day');
}

Expand Down
8 changes: 7 additions & 1 deletion apps/dav/src/components/AbsenceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ export default {
* @return {boolean}
*/
valid() {
// Translate the two date objects to midnight for an accurate comparison
const firstDay = new Date(this.firstDay?.getTime())
const lastDay = new Date(this.lastDay?.getTime())
firstDay?.setHours(0, 0, 0, 0)
lastDay?.setHours(0, 0, 0, 0)

return !!this.firstDay
&& !!this.lastDay
&& !!this.status
&& !!this.message
&& this.lastDay > this.firstDay
&& lastDay >= firstDay
},
},
methods: {
Expand Down
4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

0 comments on commit 84cfbe6

Please sign in to comment.