Skip to content

Render a document's timestamps as RFC 3339 - #53

Merged
estebanzimanyi merged 1 commit into
masterfrom
fix/timestamps-rfc3339
Aug 29, 2026
Merged

Render a document's timestamps as RFC 3339#53
estebanzimanyi merged 1 commit into
masterfrom
fix/timestamps-rfc3339

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Every format: date-time in the OGC schemas is defined against RFC 3339, whose section 5.6 writes the date and the time separated by T and the UTC offset with hours and minutes. PostgreSQL's text rendering of a timestamptz satisfies neither half — it separates with a space and abbreviates a whole-hour offset to the hour — so a Collection's temporal extent read 2026-01-01 08:00:00+00 and a MovingFeature's time the same, neither of which the format admits.

The conversion lives in the tier rather than in the SQL. The tier speaks one canonical SQL to three backends, and the expression that renders this in PostgreSQL (to_jsonb with a path extraction, or a to_char format) exists in neither of the other two; a timestamp arrives as text from all three and leaves as RFC 3339 from one place. Sub-second precision survives where it is present and no fraction is written where it is not, matching what PostgreSQL's own JsonEncodeDateTime produces.

A value the renderer cannot parse is published as it stands, so a document carrying it fails validation loudly rather than carrying a substituted instant.

Not covered here: the datetimes inside an MF-JSON temporal geometry or temporal property come from MobilityDB's asMFJSON and carry the same abbreviated offset. That is one encoder in MEOS serving every binding, so it is fixed there rather than patched per consumer.

Every `format: date-time` in the OGC schemas is defined against RFC 3339,
whose section 5.6 writes the date and the time separated by 'T' and the
UTC offset with hours AND minutes. PostgreSQL's text rendering of a
timestamptz satisfies neither half: it separates with a space and
abbreviates a whole-hour offset to the hour, so a Collection's temporal
extent and a MovingFeature's time both carried a value the format does
not admit.

The conversion lives in the tier rather than in the SQL. The tier speaks
one canonical SQL to three backends, and the expression that renders this
in PostgreSQL — to_jsonb with a path extraction, or a to_char format —
exists in neither of the other two, so the timestamp arrives as text from
all three and leaves as RFC 3339 from one place. Sub-second precision
survives where it is present and no fraction is written where it is not.

A value the renderer cannot parse is published as it stands, so a
document carrying it fails validation loudly rather than carrying a
substituted instant.
@estebanzimanyi
estebanzimanyi merged commit 5cd91f2 into master Aug 29, 2026
1 check passed
@estebanzimanyi
estebanzimanyi deleted the fix/timestamps-rfc3339 branch August 29, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant