Craticula

Dates and time zones

A calendar date without a time is kept apart from a moment in time with a zone. The adapter turns the grid's zone-less strings into typed values using the field's declared type and the zone of the request, never the zone of the server. No compiler guesses a zone.

Rule. The IR distinguishes a local date ($defs/dateValue — a calendar date, no time-of-day, no zone) from an instant ($defs/datetimeValue — a point in time plus the IANA zone used to resolve it). AG Grid emits date/datetime filter values as zone-less "YYYY-MM-DD HH:mm:ss" (or "YYYY-MM-DD") strings; resolving one of those strings into a dateValue or datetimeValue is exclusively the frontend adapter's job, using both the field's schema-declared type and the request context's zone — never the server process's local timezone, and never a zone guessed from the string itself (it doesn't carry one).

A set filter's values follow the same rule (pinned). The values of a set filter (in, wire shape {filterType:'set', values:[...]}) on a date or datetime field take the comparison filter's two wire spellings per field type (plus, on a datetime field only, an ISO-8601 instant, because a Set Filter's key for a datetime-string column is the raw data string), and the adapter resolves them with the request's zone (requestContext.zone, else the adapter's default zone). datetime: an ISO-8601 instant with Z or an offset passes unchanged; otherwise YYYY-MM-DD HH:mm:ss or YYYY-MM-DD is read as a wall-clock time in that zone and resolved to the absolute instant (datetimeValue, zone = the zone used). date: YYYY-MM-DD, or YYYY-MM-DD HH:mm:ss with a midnight time only, becomes a dateValue (no zone); a non-midnight time, or an ISO instant, is rejected, never truncated (a local date is never conflated with an instant). Any other text is a request error (malformed-request) raised by the adapter, not a later coercion error. A parse without a schema keeps the verbatim string. The customFilters typed-value path (notIn) is already typed and unaffected.

Compilers never emit a zone clause for a datetimeValue (pinned). By the time a datetimeValue reaches a compiler, value is already an absolute instant (an ISO-8601 timestamp with an explicit offset/Z) — a fixed point on the universal timeline that means the same thing regardless of any zone. The compiler compares/stores it as that absolute instant and nothing else: no AT TIME ZONE, no $dateTrunc-with-timezone, no ES time_zone parameter, ever, for a plain comparison against a datetimeValue. datetimeValue.zone is provenance metadata — it records which zone the adapter used to resolve the original wire string into that absolute instant (needed for audit/debugging and for the adapter's own resolution step) — it is not an instruction for the compiler to act on. (Zone-aware date-math — grouping rows by "day in the user's zone", for example — is a post-v1 aggregation feature, not part of comparing a datetimeValue in a filter; if and when it ships, it will need its own IR shape carrying the target zone explicitly on the aggregation, not a compiler quietly reaching into a comparison node's provenance field.) For inRange, per-boundary inclusivity (fromInclusive/toInclusive) is carried explicitly on the IR node and the compiler MUST read it from there — never assume a fixed default.

A datetime read back from a result is an absolute UTC instant (pinned; Bug #2511). Everything above is about the value going in; an execution adapter that reads a result row back must hand a datetime cell to its caller as the same kind of thing: an absolute instant, expressed in UTC. In a language whose date-time type records a kind or an offset (C#'s DateTime, a zone-aware value elsewhere), the value carries UTC, so that serialising it yields the trailing Z and nothing in between can reinterpret it. Three cases, by what the driver returns:

The driver returnsThe adapter delivers
a value that already denotes UTC (a UTC kind, an offset of zero, an ISO text ending in Z; PostgreSQL's timestamptz through a driver that returns UTC)that instant, unchanged
a value with an offset, or a local kind the driver produced by converting a zoned value (SQL Server's datetimeoffset)the same instant converted to UTC; never the offset-local wall-clock reading
a value with no zone (SQL Server's datetime2, MySQL's DATETIME, a zone-less text)that wall-clock reading as UTC

The last row is the host obligation stated for the SQL arm above, seen from the other end: a column with no zone type stores the UTC wall-clock reading (the seed of every execution-equality fixture is UTC, XEQ-2), so reading it as UTC is the only reading under which what went in is what comes out. A driver option that merely labels a zone-less value as local without converting it (MySqlConnector's DateTimeKind=Local) does not make it a zoned value: the host leaves such an option at the driver's default or at UTC, or the adapter would shift the value by the server's offset. Must NOT: deliver a zone-less value with an unspecified kind (a serialiser then drops the Z, and a consumer is left to guess), reinterpret it in the server process's local zone (SEM-4 already forbids that for the way in), or treat it as local and convert it to UTC (that would shift every instant by the server's offset). A date cell is unaffected (a local date has no zone). This rule is checked by each execution adapter's own tests, not by compile fixtures: a compiler never reads a result. Today Craticula.Dapper (DapperValueReaderDatetimeTests) and Craticula.EntityFrameworkCore (Bug #2798, EfCoreDatetimeKindTests) are covered by such tests; MongoDB's and OpenSearch's readers return UTC by construction. EF Core: the adapter has no reader of its own, so it applies the same table to every DateTime or DateTimeOffset cell of a page or an export row after EF has materialised it, whatever the provider; a host therefore needs no UTC value converter for the result side. The comparison side stays the host's obligation as above. For SQLite that obligation includes the binding: EF binds a DateTime in its own yyyy-MM-dd HH:mm:ss form, so the host maps every datetime to and from the stored yyyy-MM-ddTHH:mm:ss.fffZ text on its DbContext, or an eq, a range bound and a datetime-sorted export return wrong rows without an error (a walk that meets the row its previous chunk ended on stops with an exception) (Bug #2805, EfCoreHostObligationTests).

MongoDB representation of dateValue (pinned): a plain ISO date string, never a BSON Date. MongoDB's Date type has no "calendar date, no time-of-day" concept — every BSON Date is an instant. Storing/comparing a dateValue as a BSON Date therefore requires silently promoting it to some midnight instant, and "midnight in which zone?" has no answer for a value that was never an instant in the first place — exactly the conflation this rule's own second "must NOT" (below) forbids "without that promotion being an explicit, documented adapter decision." Rather than making that decision implicitly inside every Mongo compiler, the pinned mechanism sidesteps it: dateValue compiles to the ISO calendar-date string itself ("1990-05-12"), compared as a plain BSON string. Lexicographic string comparison on YYYY-MM-DD already matches chronological order, so $gte/$lt work correctly with no Date promotion, no zone, and no ambiguity. datetimeValue (an instant) still compiles to a BSON Date — extended-JSON's $date field requires a full instant string with an explicit offset/Z ("2026-01-01T00:00:00Z"), never a bare calendar date.

Not yet pinned — flagged in the TRD, stated here rather than guessed at. The TRD (§7.4) explicitly marks the exact default boundary inclusivity that AG Grid's own simple date filter uses for inRange (its stated default is exclusive of both bounds) as "verify at implementation time and freeze" — i.e., a value to be captured from a live grid and locked into fixtures by #1630, not a certainty this document should assert today. What is pinned by this rule is the mechanism: inclusivity flags are always explicit on the IR node and always read literally by the compiler. What is not yet pinned is the specific default value the adapter should choose when AG Grid's own request doesn't make it explicit. Treat any inclusive/exclusive example below as illustrative of the mechanism, not as the frozen default.

Rationale. Three naive failure modes, all seen in hand-rolled translations: (1) treating every date as a UTC instant regardless of its declared type — a local-date field compared this way shifts by a day for any user not in UTC, the classic "date is off by one near midnight" bug; (2) parsing AG Grid's zone-less datetime string using the server process's own local timezone, which makes the exact same IR return different rows depending on the deployment environment's TZ setting — a compiler that isn't even deterministic on its own inputs; (3) hardcoding inRange boundaries as always-inclusive (SQL BETWEEN's familiar default) regardless of what the IR's explicit flags say, so a row sitting exactly on a boundary appears in the grid's client-side row model and silently disappears once the same filter is compiled for SSRM. All three are exactly the kind of "usually wrong" translation TRD §7's opening line calls out — dates and zones are where naive compilers most often diverge from what the grid itself shows the user.

Worked example — inRange on createdAt (an instant field), from 2026-01-01T00:00:00Z (inclusive) to 2026-02-01T00:00:00Z (exclusive), as resolved by the adapter for illustration:

Must NOT.

Fixture format note. A datetimeValue fixture's expected artifacts are only reproducible if the adapter's resolved value AND the request-context zone it used are both visible in the fixture inputs — otherwise a port author must guess the zone the original fixture author assumed. agGridRequest.json fixtures needing this carry an optional requestContext: { "zone": "<IANA id>" } sibling field alongside the AG Grid wire shape (the same "documented extension beyond AG Grid's own wire format" pattern as customFilters, OQ-11) — see spec/fixtures/README.md.

requestContext carries a second, related field for the same reproducibility reason: now (an ISO-8601 instant), required by any fixture whose expected artifacts depend on what "now" was — i.e. every AG-2 date-preset fixture, since today/last7Days/... resolve relative to the current instant. The two fields differ in status, and the difference is normative: zone is read off the wire, now is not. An implementation resolves presets against its own injected clock and MUST NOT honor a client-supplied now — a request that could redefine what "last 7 days" means would let any caller move the window at will. now exists so a conformance harness can pin its clock and replay the fixture deterministically; it is a harness instruction, never a wire input. See spec/fixtures/date-presets/README.md.

Cross-links. $defs/dateValue, $defs/datetimeValue, $defs/rangeComparisonNode (fromInclusive, toInclusive), $defs/typedValue.