Skip to content

Commit 31826fd

Browse files
committed
edited notes: move formatMap on module level
1 parent 7777779 commit 31826fd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/server/src/routes/api/edited-notes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ function getNotePathData(note: BNote): NotePath | undefined {
8888
}
8989
}
9090

91+
const formatMap = new Map<string, { format: string, addUnit: dayjs.UnitType }>([
92+
["today", { format: "YYYY-MM-DD", addUnit: "day" }],
93+
["month", { format: "YYYY-MM", addUnit: "month" }],
94+
["year", { format: "YYYY", addUnit: "year" }]
95+
]);
96+
9197
function formatDateFromKeywordAndDelta(
9298
startingDate: dayjs.Dayjs,
9399
keyword: string,
94100
delta: number
95101
): string {
96-
const formatMap = new Map<string, { format: string, addUnit: dayjs.UnitType }>([
97-
["today", { format: "YYYY-MM-DD", addUnit: "day" }],
98-
["month", { format: "YYYY-MM", addUnit: "month" }],
99-
["year", { format: "YYYY", addUnit: "year" }]
100-
]);
101-
102102
const handler = formatMap.get(keyword);
103103

104104
if (!handler) {
@@ -144,7 +144,7 @@ export function resolveDateParams(dateStr: string): DateFilter {
144144

145145
if (!match) {
146146
return {
147-
date: `${dateStr}`
147+
date: dateStr
148148
}
149149
}
150150

@@ -154,7 +154,7 @@ export function resolveDateParams(dateStr: string): DateFilter {
154154
const clientDate = dayjs(dateUtils.localNowDate());
155155
const date = formatDateFromKeywordAndDelta(clientDate, keyword, delta);
156156
return {
157-
date: `${date}`
157+
date: date
158158
}
159159
}
160160

0 commit comments

Comments
 (0)