(date1: string, date2: string)
| 360 | * Safe date comparison for before/after relationships |
| 361 | */ |
| 362 | export 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 |
no test coverage detected