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

Function isSameDateSafe

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

Source from the content-addressed store, hash-verified

335 * Safe date comparison that handles mixed timezone contexts
336 */
337export function isSameDateSafe(date1: string, date2: string): boolean {
338 try {
339 // For date-only comparisons, we need to extract the date parts
340 // and compare them as calendar dates
341 const date1Part = getDatePart(date1);
342 const date2Part = getDatePart(date2);
343
344 // Use UTC anchors for consistent comparison
345 const d1 = parseDateToUTC(date1Part);
346 const d2 = parseDateToUTC(date2Part);
347 return d1.getTime() === d2.getTime();
348 } catch (error) {
349 tasknotesLogger.error("Error comparing dates:", {
350 category: "validation",
351 operation: "comparing-dates",
352 details: { date1, date2 },
353 error: error,
354 });
355 return false;
356 }
357}
358
359/**
360 * Safe date comparison for before/after relationships

Calls 3

getDatePartFunction · 0.85
parseDateToUTCFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected