refactor: centralize week calculation logic and standardize schedule boundary date normalization across client and server
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const getMondayWeekStart = (date: dayjs.Dayjs = dayjs()): dayjs.Dayjs => {
|
||||
return date.startOf("day").subtract((date.day() + 6) % 7, "day");
|
||||
};
|
||||
|
||||
export const getSundayWeekEnd = (date: dayjs.Dayjs = dayjs()): dayjs.Dayjs => {
|
||||
return getMondayWeekStart(date).add(6, "day");
|
||||
};
|
||||
Reference in New Issue
Block a user