mirror of
https://github.com/zadam/trilium.git
synced 2025-12-06 07:24:25 +01:00
edited notes: move formatMap on module level
This commit is contained in:
parent
152c7aea23
commit
bcb8f29494
@ -88,17 +88,17 @@ function getNotePathData(note: BNote): NotePath | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatMap = new Map<string, { format: string, addUnit: dayjs.UnitType }>([
|
||||||
|
["today", { format: "YYYY-MM-DD", addUnit: "day" }],
|
||||||
|
["month", { format: "YYYY-MM", addUnit: "month" }],
|
||||||
|
["year", { format: "YYYY", addUnit: "year" }]
|
||||||
|
]);
|
||||||
|
|
||||||
function formatDateFromKeywordAndDelta(
|
function formatDateFromKeywordAndDelta(
|
||||||
startingDate: dayjs.Dayjs,
|
startingDate: dayjs.Dayjs,
|
||||||
keyword: string,
|
keyword: string,
|
||||||
delta: number
|
delta: number
|
||||||
): string {
|
): string {
|
||||||
const formatMap = new Map<string, { format: string, addUnit: dayjs.UnitType }>([
|
|
||||||
["today", { format: "YYYY-MM-DD", addUnit: "day" }],
|
|
||||||
["month", { format: "YYYY-MM", addUnit: "month" }],
|
|
||||||
["year", { format: "YYYY", addUnit: "year" }]
|
|
||||||
]);
|
|
||||||
|
|
||||||
const handler = formatMap.get(keyword);
|
const handler = formatMap.get(keyword);
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
@ -144,7 +144,7 @@ export function resolveDateParams(dateStr: string): DateFilter {
|
|||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return {
|
return {
|
||||||
date: `${dateStr}`
|
date: dateStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ export function resolveDateParams(dateStr: string): DateFilter {
|
|||||||
const clientDate = dayjs(dateUtils.localNowDate());
|
const clientDate = dayjs(dateUtils.localNowDate());
|
||||||
const date = formatDateFromKeywordAndDelta(clientDate, keyword, delta);
|
const date = formatDateFromKeywordAndDelta(clientDate, keyword, delta);
|
||||||
return {
|
return {
|
||||||
date: `${date}`
|
date: date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user