Skip to content

Conversation

@antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented Oct 13, 2025

@BenMorel I found that it's pretty difficult to parse Postgres TIMESTAMP WITH TIMEZONE column value using this library. Because PG omits :[mm] part if they are :00 in offset. Because of it we need to analyse response from database of each timestamp field and append :00 suffix on the end (if it's missing).

ISO 8601 allows to omit minutes. Let's support TimeZoneOffset with ±[hh] only.

The UTC offset is appended directly to the time instead of "Z" suffix above; other nautical time zone letters are not used. The offset is applied to UTC to get the civil time in the designated time zone in the format '±[hh]:[mm]', '±[hh][mm]', or '±[hh]'.

INSERT INTO test (ts_with_tz) VALUES ('2024-01-01 09:00:00Z');

SET TIME ZONE 'UTC';
SELECT ts_with_tz FROM test;
-- 2024-01-01 09:00:00+00

SET TIME ZONE INTERVAL '+03:00';
SELECT ts_with_tz FROM test;
-- 2024-01-01 12:00:00+03

SET TIME ZONE INTERVAL '+03:01';
SELECT ts_with_tz FROM test;
-- 2024-01-01 12:01:00+03:01

Note: Many IDEs and DB tools appends :00 omitted seconds suffix before the output, so it's visible only in raw DB responses.

@antonkomarev antonkomarev changed the title [Draft] Allow to parse TimeZoneOffset with hours only Allow to parse TimeZoneOffset with ±[hh] only Oct 13, 2025
@BenMorel BenMorel merged commit b9e9869 into brick:master Nov 11, 2025
7 checks passed
@BenMorel
Copy link
Member

Makes sense. Thank you, @antonkomarev!

@BenMorel
Copy link
Member

Released as 0.8.1.

@antonkomarev antonkomarev deleted the allow-offset-without-minutes branch November 11, 2025 16:37
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.

2 participants