Skip to content

Commit 6f025a1

Browse files
committed
fix(web): Compute start-end date correctly for someday month
1 parent 330236c commit 6f025a1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/web/src/common/utils/draft/someday.draft.util.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ export const createSomedayDraft = async (
1313
activity: Activity_DraftEvent,
1414
dispatch: Dispatch,
1515
) => {
16-
const startDate = startOfView.format(YEAR_MONTH_DAY_FORMAT);
17-
const endDate = endOfView.format(YEAR_MONTH_DAY_FORMAT);
16+
let startDate: string;
17+
let endDate: string;
18+
19+
if (category === Categories_Event.SOMEDAY_WEEK) {
20+
startDate = startOfView.format(YEAR_MONTH_DAY_FORMAT);
21+
endDate = endOfView.format(YEAR_MONTH_DAY_FORMAT);
22+
} else {
23+
// Someday month
24+
startDate = startOfView.startOf("month").format(YEAR_MONTH_DAY_FORMAT);
25+
// `endDate` is the last day of the month, hence why we need to use `startOfView`, because
26+
// `endOfView` could be in the next month relative to `startOfView`
27+
endDate = startOfView.endOf("month").format(YEAR_MONTH_DAY_FORMAT);
28+
}
1829

1930
const event = await assembleDefaultEvent(category, startDate, endDate);
2031

0 commit comments

Comments
 (0)