(date1: string, date2: string)
| 335 | * Safe date comparison that handles mixed timezone contexts |
| 336 | */ |
| 337 | export 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 |
no test coverage detected