MCPcopy
hub / github.com/callumalpass/tasknotes / normalizeDate

Method normalizeDate

src/utils/TasksPluginParser.ts:469–494  ·  view source on GitHub ↗
(dateString: string | undefined)

Source from the content-addressed store, hash-verified

467 }
468
469 private static normalizeDate(dateString: string | undefined): string | undefined {
470 if (!dateString) {
471 return undefined;
472 }
473
474 const trimmed = dateString.trim();
475 if (!/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) {
476 return undefined;
477 }
478
479 try {
480 const date = parseDateToUTC(trimmed);
481 if (isNaN(date.getTime())) {
482 return undefined;
483 }
484
485 const year = date.getUTCFullYear();
486 if (year < 1900 || year > 2100) {
487 return undefined;
488 }
489
490 return formatDateForStorage(date);
491 } catch {
492 return undefined;
493 }
494 }
495
496 private static normalizePriority(value: string | undefined): string | undefined {
497 if (!value) {

Callers 2

consumeEmojiDateFieldMethod · 0.95
assignDateFieldMethod · 0.95

Calls 2

parseDateToUTCFunction · 0.90
formatDateForStorageFunction · 0.90

Tested by

no test coverage detected