MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / dateAddRuntimeValue

Function dateAddRuntimeValue

src/api/TaskNotesAPI.ts:3243–3260  ·  view source on GitHub ↗
(value: {
	fn: "dateAdd";
	value: TaskNotesRuntimeValue;
	amount: number;
	unit: "day" | "week" | "month";
})

Source from the content-addressed store, hash-verified

3241}
3242
3243function dateAddRuntimeValue(value: {
3244 fn: "dateAdd";
3245 value: TaskNotesRuntimeValue;
3246 amount: number;
3247 unit: "day" | "week" | "month";
3248}): string {
3249 const baseValue = toFilterConditionValue(value.value);
3250 const base =
3251 baseValue === "today"
3252 ? new Date()
3253 : typeof baseValue === "string"
3254 ? new Date(baseValue)
3255 : new Date();
3256 if (value.unit === "day") base.setDate(base.getDate() + value.amount);
3257 if (value.unit === "week") base.setDate(base.getDate() + value.amount * 7);
3258 if (value.unit === "month") base.setMonth(base.getMonth() + value.amount);
3259 return base.toISOString().slice(0, 10);
3260}
3261
3262function invertRuntimePredicate(
3263 predicate: TaskNotesRuntimeNormalizedPredicate

Callers 1

toFilterConditionValueFunction · 0.85

Calls 2

toFilterConditionValueFunction · 0.85
getDateMethod · 0.65

Tested by

no test coverage detected