Skip to content

Commit 64f8ca1

Browse files
committed
fix: resolving correct date for sundays
1 parent 5cb8fb5 commit 64f8ca1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libs/ui/src/utils/date.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export function formatDate(date: Date, dayjsFormatTemplate: string) {
77
export const getTime = (date: Date) => formatDate(date, "HH:mm");
88

99
export function getDateFromTimeAndWeekday(time: string, weekday: number) {
10-
const startOfWeek = dayjs().startOf("week");
11-
12-
return dayjs(time, "HH:mm:ss").set("date", startOfWeek.date()).add(weekday, "days").toDate();
10+
return dayjs(time, "HH:mm:ss")
11+
.set("day", weekday)
12+
.add(weekday === 0 ? 1 : 0, "week")
13+
.toDate();
1314
}

0 commit comments

Comments
 (0)