mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
also get booked days from calendar
This commit is contained in:
@@ -16,3 +16,7 @@ export function getNextBigger<T>(array: T[], pivot: T): T {
|
||||
|
||||
return array.sort().find((day) => day > pivot)
|
||||
}
|
||||
|
||||
export function uniqueFilter(value, index, self) {
|
||||
return self.indexOf(value) === index;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { parse, format, addDays } from 'date-fns'
|
||||
import { parse, format, addDays, subDays } from 'date-fns'
|
||||
import { utcToZonedTime } from 'date-fns-tz'
|
||||
|
||||
const FRONTEND_FORMAT = 'dd.MM.yyyy'
|
||||
@@ -21,9 +21,11 @@ export function daysFormatFrontend(days: string[]): string {
|
||||
export function getDays({
|
||||
startDate,
|
||||
endDate,
|
||||
endDateExclusive = false,
|
||||
}: {
|
||||
startDate: Date
|
||||
endDate: Date
|
||||
endDateExclusive?: boolean
|
||||
}): string[] {
|
||||
let currentDay = new Date(startDate.getTime())
|
||||
const days = [dateFormatBackend(currentDay)]
|
||||
@@ -32,7 +34,9 @@ export function getDays({
|
||||
return days
|
||||
}
|
||||
|
||||
while (currentDay < endDate) {
|
||||
const inclusiveEndDate = endDateExclusive ? subDays(endDate, 1) : endDate;
|
||||
|
||||
while (currentDay < inclusiveEndDate) {
|
||||
currentDay = addDays(currentDay, 1)
|
||||
days.push(dateFormatBackend(currentDay))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user