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

Function parseTimestamp

src/utils/dateUtils.ts:799–820  ·  view source on GitHub ↗
(timestampString: string)

Source from the content-addressed store, hash-verified

797 * Safe timestamp parsing for display and comparison
798 */
799export 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

Callers 2

dateUtils.test.tsFile · 0.90

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected