Repository navigation
fix(dataview): serialize date filter bounds as UTC ISO timestamps - #153
Merged
Merged
Conversation
The date filter built a local ISO string from the local wall-clock time plus getTimezoneOffset(). For historical dates in zones with a local mean time offset (e.g. Europe/Prague before 1891, +0:57:44), V8 returns a fractional offset, producing "+00:57.733333333333334", which Postgres rejects; JavaScriptCore rounds the offset instead, silently shifting the bound by 44 seconds. Serialize the same instant with toISOString(), and ignore years outside 1000-9999, which a date input reports while the user is typing the year. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
toISOString() moved the calendar day for `date` columns east of UTC: Postgres casts the bound to `date` and drops the time and zone, so 2024-01-15 local midnight in Prague became 2024-01-14. Restore the local-offset string, but derive the offset from the local fields instead of getTimezoneOffset() (fractional in V8, rounded in JavaScriptCore for LMT dates) and emit seconds when the offset has them. Pin the date filter tests to Europe/Prague with literal expectations and restore the zone by name, since deleting TZ does not reset it in Bun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
Review round 1Reviewer: independent Claude subagent (general-purpose, Claude Opus 5.5), not sharing the author's context Findings
|
Member
Author
Review round 1: response
|
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
The date filter serialized its bounds as a local ISO string built from the local wall-clock time plus
getTimezoneOffset(). For historical dates in zones that used local mean time (e.g.Europe/Praguebefore 1891, +0:57:44), the offset is not a whole number of minutes:0020-10-30T00:00:00+00:57.733333333333334. Postgres rejects it and the Contember API answers 500.This is easy to hit: a date input reports partial years (
0002,0020,0202) on each keystroke while the user types a year.Fix
YYYY-MM-DDT00:00:00±HH:MM, sodatecolumns keep the local calendar day). Compute the offset from the local fields, not fromgetTimezoneOffset(), and write seconds when the offset has them (+00:57:44). Filter semantics are unchanged.Tests
tests/unit/dataview/filterHandlers.test.ts: pinned toEurope/Praguewith literal expectations: a 2024 case, an 1890 LMT case (fails on the old code) and partial-year cases.bun run typecheck,eslinton changed files,bun run test(2203 pass).Status
changes. 1 major, 2 minor, 1 nit, all fixed in a986441🤖 Generated with Claude Code