GUACAMOLE-1020: Fix issues with Timezone offset and next day calculations.

This commit is contained in:
Virtually Nick
2023-11-07 19:44:30 -05:00
parent 1b7c35e189
commit 422db894f3
2 changed files with 79 additions and 21 deletions

View File

@@ -125,6 +125,14 @@ public class DailyRestriction {
DayOfWeek currentDay = LocalDate.now(ZoneId.of("UTC")).getDayOfWeek();
LocalTime currentTime = LocalTime.now(ZoneId.of("UTC"));
// If end time is less than the start time, we check the remainder of this
// day and the beginning of the next day.
if (endTime.isBefore(startTime)) {
if (weekDays.contains(currentDay) && currentTime.isAfter(startTime) && currentTime.isBefore(LocalTime.MAX))
return true;
return (weekDays.contains(currentDay.plus(1)) && currentTime.isAfter(LocalTime.MIDNIGHT) && currentTime.isBefore(endTime));
}
// Check that we are in the specified time restriction
return (weekDays.contains(currentDay) && currentTime.isAfter(startTime) && currentTime.isBefore(endTime));
}