fix: parse SQLite UTC timestamps with explicit Z suffix#229
Merged
jalehman merged 2 commits intoApr 3, 2026
Conversation
SQLite datetime('now') stores UTC timestamps without a Z suffix.
JavaScript's Date constructor parses bare datetime strings as local time
per ECMA-262, causing timestamps to shift by the local timezone offset.
This adds a parseUtcTimestamp() helper that appends 'Z' before parsing,
and applies it to all new Date(row.*) calls in conversation-store,
summary-store, and migration.
Fixes Martian-Engineering#216
4f165fc to
788daf8
Compare
Keep explicit timezone offsets intact in the shared timestamp parser while still normalizing bare SQLite datetime('now') values to UTC. Add focused parser coverage for bare, Z-suffixed, and offset-bearing timestamps, and include a patch changeset for the behavior fix.
Regeneration-Prompt: |
Address the PR review finding on the shared SQLite timestamp parser introduced for issue Martian-Engineering#216. Preserve the intended fix for bare datetime('now') strings that lack a timezone suffix, but do not break timestamps that already include Z or an explicit offset like +02:00. Add narrow tests that prove all three cases still parse correctly, and include a patch changeset because this affects user-visible timestamp handling.
Contributor
|
Thank you! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SQLite's
datetime('now')produces bare strings like2026-03-30 23:11:15without a timezone indicator. Per ECMA-262 §21.4.3.2,new Date()parses these as local time, silently shifting results when the runtime'sTZis anything other than UTC.This causes wrong timestamps in
lcm_grep,lcm_expand, and summary injection when running in containers or hosts with a non-UTC timezone (e.g.TZ=America/Los_Angeles).Fix
src/store/parse-utc-timestamp.tswithparseUtcTimestamp()andparseUtcTimestampOrNull()helpers that appendZto bare timestamps before parsingnew Date(row.*)calls inconversation-store.ts,summary-store.ts, andmigration.tsZor±HH:MM) are parsed as-isChanges
src/store/parse-utc-timestamp.ts— new utility (30 lines)src/store/conversation-store.ts— import + replace 7 call sitessrc/store/summary-store.ts— import + replace 9 call sitessrc/db/migration.ts— delegateparseTimestamp()to new helperFixes #216