Skip to content

enh: timezone to conform iso8601 - main#35081

Merged
guanshengliang merged 6 commits intomainfrom
enh/iso8601-main
Apr 9, 2026
Merged

enh: timezone to conform iso8601 - main#35081
guanshengliang merged 6 commits intomainfrom
enh/iso8601-main

Conversation

@localvar
Copy link
Copy Markdown
Contributor

@localvar localvar commented Apr 8, 2026

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/tz format specifier for to_char/to_timestamp.

timezone validation (builtins.c)

  • valid hour range extended from ±12 to ±14
  • valid minute range extended to 0-59 (was restricted to 0/30 for specific hours), with guard for hour==14 requiring minute==0

timezone parsing (ttime.c)

  • parseTimezone: extended hour limit to 14
  • New TSFKW_TZ format specifier: outputs ±HH:MM in to_char, parses Z, ±HH, ±HH:MM, ±HHMM in to_timestamp
  • Added tzMinute handling in char2ts for proper minute-level timezone offset application
  • Refactor function keywordSearch to avoid using TSFormatKeywordIndex which is hard to maintain

tests

  • test_fun_sca_to_iso8601.py: extended timezone coverage, moved valid cases from error list
  • test_fun_sca_to_timestamp.py: added TZ format tests and roundtrip verification
  • test_fun_sca_to_unixtimestamp.py: added extended timezone epoch roundtrip tests
  • test_fun_sca_timezone.py: replaced commented-out error cases with proper valid/error cases
  • test_query_sub_interval.py: added TZ format subquery tests

documentation

  • English and Chinese docs: added TZ/tz format description, timezone range note for TO_ISO8601

Issue(s)

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings April 8, 2026 05:41
@localvar localvar changed the title enh: timezone to conform iso8601 enh: timezone to conform iso8601 - main Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:00 range.
  • Add TZ/tz format keyword support for to_char / to_timestamp roundtrips (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.

Comment thread source/common/src/ttime.c
Comment thread source/common/src/ttime.c Outdated
Comment thread source/common/src/ttime.c
Comment thread .github/scripts/check_enum_append_only.py
Comment thread test/cases/09-DataQuerying/08-SubQuery/test_query_sub_interval.py
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread source/common/src/ttime.c Outdated
@guanshengliang guanshengliang merged commit ce01f7a into main Apr 9, 2026
21 of 24 checks passed
@localvar localvar deleted the enh/iso8601-main branch April 9, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants