enh: timezone to conform iso8601 - main#35081
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances TDengine’s timezone handling to better conform to ISO-8601/RFC3339, expanding supported offset ranges and formats, adding a TZ/tz formatter token, and updating tests/docs accordingly.
Changes:
- Extend timezone offset parsing/validation to support
Z,±HH,±HHMM,±HH:MM, including fractional-hour offsets and the-14:00..+14:00range. - Add
TZ/tzformat keyword support forto_char/to_timestamproundtrips (outputting+HH:MM). - Expand scalar/query test coverage and update English/Chinese SQL function documentation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
source/common/src/ttime.c |
Adds TZ keyword parsing/formatting and updates timezone parsing/validation logic. |
source/libs/function/src/builtins.c |
Updates ISO8601 timezone argument validation for built-in functions. |
test/cases/11-Functions/01-Scalar/test_fun_sca_to_unixtimestamp.py |
Adds to_unixtimestamp tests for extended timezone offsets and compact formats. |
test/cases/11-Functions/01-Scalar/test_fun_sca_to_timestamp.py |
Adds to_timestamp tests for TZ parsing and roundtrip behavior with to_char. |
test/cases/11-Functions/01-Scalar/test_fun_sca_to_iso8601.py |
Expands to_iso8601 timezone parameter tests and invalid-range coverage. |
test/cases/11-Functions/01-Scalar/test_fun_sca_timezone.py |
Updates timezone insert/query tests for newly valid offsets and stricter invalid cases. |
test/cases/09-DataQuerying/08-SubQuery/test_query_sub_interval.py |
Adds subquery coverage for TZ formatting and to_timestamp(to_char(...)) roundtrips. |
docs/zh/14-reference/03-taos-sql/22-function.md |
Documents TZ/tz formatter and timezone offset range limits for TO_ISO8601. |
docs/en/14-reference/03-taos-sql/22-function.md |
Documents TZ/tz formatter and timezone offset range limits for TO_ISO8601. |
.github/scripts/check_enum_append_only.py |
Updates enum append-only checker to allow broader ignore matching for one enum. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request adds support for the TZ timezone format in TO_CHAR and TO_TIMESTAMP, extends the valid timezone offset range to +/-14:00, and updates the enum check script to support wildcards. Changes include documentation updates, refactored timezone parsing, and an optimized keyword search. Review feedback identifies a critical race condition in the keyword index initialization and a potential integer overflow risk.
b9fc077 to
7daafbd
Compare
Description
Extend timezone offset support from ±12:00 to ±14:00 (covering all real-world timezones including UTC+13, UTC+14, UTC+5:45, etc.) and implement the new
TZ/tzformat specifier forto_char/to_timestamp.timezone validation (
builtins.c)timezone parsing (
ttime.c)parseTimezone: extended hour limit to 14TSFKW_TZformat specifier: outputs±HH:MMinto_char, parsesZ,±HH,±HH:MM,±HHMMinto_timestamptzMinutehandling inchar2tsfor proper minute-level timezone offset applicationkeywordSearchto avoid usingTSFormatKeywordIndexwhich is hard to maintaintests
test_fun_sca_to_iso8601.py: extended timezone coverage, moved valid cases from error listtest_fun_sca_to_timestamp.py: added TZ format tests and roundtrip verificationtest_fun_sca_to_unixtimestamp.py: added extended timezone epoch roundtrip teststest_fun_sca_timezone.py: replaced commented-out error cases with proper valid/error casestest_query_sub_interval.py: added TZ format subquery testsdocumentation
TZ/tzformat description, timezone range note forTO_ISO8601Issue(s)
Checklist
Please check the items in the checklist if applicable.