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

Function isBeforeDateSafe

src/utils/dateUtils.ts:362–380  ·  view source on GitHub ↗
(date1: string, date2: string)

Source from the content-addressed store, hash-verified

360 * Safe date comparison for before/after relationships
361 */
362export function isBeforeDateSafe(date1: string, date2: string): boolean {
363 try {
364 // For date-only comparisons, use UTC anchors
365 const date1Part = getDatePart(date1);
366 const date2Part = getDatePart(date2);
367
368 const d1 = parseDateToUTC(date1Part);
369 const d2 = parseDateToUTC(date2Part);
370 return d1.getTime() < d2.getTime();
371 } catch (error) {
372 tasknotesLogger.error("Error comparing dates for before:", {
373 category: "validation",
374 operation: "comparing-dates",
375 details: { date1, date2 },
376 error: error,
377 });
378 return false;
379 }
380}
381
382/**
383 * Get today in appropriate format for comparison

Callers 6

getOverdueTaskPathsMethod · 0.90
dateUtils.test.tsFile · 0.90
isPastDateFunction · 0.85

Calls 3

getDatePartFunction · 0.85
parseDateToUTCFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected