Render a document's timestamps as RFC 3339 - #53
Merged
Conversation
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.
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.
Every
format: date-timein the OGC schemas is defined against RFC 3339, whose section 5.6 writes the date and the time separated byTand 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 read2026-01-01 08:00:00+00and a MovingFeature'stimethe 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_jsonbwith a path extraction, or ato_charformat) 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 ownJsonEncodeDateTimeproduces.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
asMFJSONand carry the same abbreviated offset. That is one encoder in MEOS serving every binding, so it is fixed there rather than patched per consumer.