From c18363c74f1cb68ba91b9ab145f07932d911a45d Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Fri, 26 Dec 2025 13:44:24 -0500 Subject: [PATCH] fix time issue --- src/components/blog/TextEditor.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/blog/TextEditor.tsx b/src/components/blog/TextEditor.tsx index 9a280b8..6da9f10 100644 --- a/src/components/blog/TextEditor.tsx +++ b/src/components/blog/TextEditor.tsx @@ -757,6 +757,16 @@ export default function TextEditor(props: TextEditorProps) { } }; + // Parse UTC datetime string from SQLite to JavaScript Date + // SQLite datetime('now') returns format: "YYYY-MM-DD HH:MM:SS" in UTC + const parseUTCDateTime = (utcDateString: string): Date => { + // SQLite returns datetime in format "YYYY-MM-DD HH:MM:SS" + // We need to append 'Z' to indicate UTC, or convert to ISO format + // Replace space with 'T' and append 'Z' for proper UTC parsing + const isoString = utcDateString.replace(" ", "T") + "Z"; + return new Date(isoString); + }; + // Format relative time for history display const formatRelativeTime = (date: Date): string => { const now = new Date(); @@ -821,11 +831,12 @@ export default function TextEditor(props: TextEditorProps) { ); // Convert database history to HistoryNode format with reconstructed content + // Database stores timestamps in UTC, so we need to parse them correctly const historyNodes: HistoryNode[] = dbHistory.map((entry) => ({ id: `db-${entry.id}`, dbId: entry.id, content: entry.content, // Full reconstructed content from diffs - timestamp: new Date(entry.created_at) + timestamp: parseUTCDateTime(entry.created_at) // Parse UTC timestamp })); setHistory(historyNodes);