(timestampString: string)
| 797 | * Safe timestamp parsing for display and comparison |
| 798 | */ |
| 799 | export function parseTimestamp(timestampString: string): Date { |
| 800 | try { |
| 801 | if (!timestampString) { |
| 802 | throw new Error("Timestamp string cannot be empty"); |
| 803 | } |
| 804 | |
| 805 | // Always use parseISO for timestamps as they should be in ISO format |
| 806 | const parsed = parseISO(timestampString); |
| 807 | if (!isValid(parsed)) { |
| 808 | throw new Error(`Invalid timestamp: ${timestampString}`); |
| 809 | } |
| 810 | return parsed; |
| 811 | } catch (error) { |
| 812 | tasknotesLogger.error("Error parsing timestamp:", { |
| 813 | category: "validation", |
| 814 | operation: "parsing-timestamp", |
| 815 | details: { timestampString }, |
| 816 | error: error, |
| 817 | }); |
| 818 | throw error; |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | /** |
| 823 | * Format timestamp for display in user's timezone |
no test coverage detected