Skip to content

Commit

Permalink
account for timezone in getAvailableDatesAndHours
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhdr1 committed Mar 14, 2024
1 parent 8a55b6b commit a9d56a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/api/src/therapist/getAvailableDatesAndHours.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { addDays, format, isSameDay, isWeekend } from "date-fns";
import { addDays, addHours, format, isSameDay, isWeekend } from "date-fns";

import { type Appointment, type Hour, type Therapist } from "@acme/db";

export function getAvailableDatesAndHours({
therapist,
numberOfDays = 30,
startingDate = new Date(),
// account for the time zone difference
// couldn't get date-fns-tz to work
startingDate = addHours(new Date(), -3),
}: {
therapist: Therapist & {
hours: Hour[];
Expand Down Expand Up @@ -83,6 +85,5 @@ export function getAvailableDatesAndHours({
},
{} as Record<number, { date: Date; hours: Hour[] }[]>,
);

return allHoursInNext30DaysOrganized;
}

0 comments on commit a9d56a4

Please sign in to comment.