switch to prisma

This commit is contained in:
Thomas Ruoff
2022-10-11 11:43:32 +02:00
parent 41342475ba
commit 1ef9b14e95
28 changed files with 764 additions and 780 deletions

View File

@@ -1,4 +1,4 @@
import { parse, format, addDays, subDays } from 'date-fns'
import { parse, format, addDays, subDays, differenceInDays } from 'date-fns'
import { utcToZonedTime } from 'date-fns-tz'
const FRONTEND_FORMAT = 'dd.MM.yyyy'
@@ -23,18 +23,18 @@ export function getDays({
endDate,
endDateExclusive = false,
}: {
startDate: Date
endDate: Date
startDate: string,
endDate: string,
endDateExclusive?: boolean
}): string[] {
let currentDay = new Date(startDate.getTime())
let currentDay = new Date(startDate);
const days = [dateFormatBackend(currentDay)]
if (!endDate) {
return days
}
const inclusiveEndDate = endDateExclusive ? subDays(endDate, 1) : endDate
const inclusiveEndDate = endDateExclusive ? subDays(new Date(endDate), 1) : new Date(endDate)
while (currentDay < inclusiveEndDate) {
currentDay = addDays(currentDay, 1)
@@ -84,3 +84,8 @@ export function nowInTz(timezone = 'Europe/Berlin'): Date {
export function getNextDay(date: Date) {
return addDays(date, 1)
}
export function getDayCount({ startDate, endDate }: { startDate: string, endDate: string }) {
// TODO: check if this actually works as expected
return differenceInDays(new Date(startDate), new Date(endDate)) + 1 // add one as it only counts full days;
}