Skip to content

Render tz-aware times as local times without an offset - #613

Merged
frostming merged 1 commit into
python-poetry:masterfrom
Master-Norna:fix/time-tzinfo-serialization
Sep 30, 2026
Merged

frostming merged 1 commit into
python-poetry:masterfrom
Master-Norna:fix/time-tzinfo-serialization

Conversation

@Master-Norna

Copy link
Copy Markdown
Contributor

Summary

item() and Time._new built the raw literal with time.isoformat(), which includes the UTC offset for tz-aware values - e.g. 07:32:00+02:00. TOML local times have no offset or timezone (the spec's examples are plain 07:32:00), and this library's own parser rejects the offset, so the serialized document was invalid and could not be read back:

i = item(time(7, 32, tzinfo=timezone(timedelta(hours=2))))
i.as_string()   # before: '07:32:00+02:00'  (rejected by tomlkit.parse)
                # after:  '07:32:00'

Render from hour/minute/second/microsecond only. Naive times are byte-for-byte unchanged.

Agent Drafting Metadata

  • Agent: Claude (Anthropic)
  • Model: Claude Opus
  • Notes: Agent assisted with investigation and drafting; the fix, tests and verification were reviewed by the submitter. Full suite passes (1059 passed).

@frostming

Copy link
Copy Markdown
Contributor

Please resolve the conflict

@frostming frostming added the pending merge This PR is okay to merge but needs extra actions label Sep 30, 2026
item() and Time._new built the raw literal with time.isoformat(), which includes the UTC offset for tz-aware values - e.g. 07:32:00+02:00. TOML local times have no offset or timezone (the spec's examples are plain 07:32:00), and this library's own parser rejects the offset, so the serialized document was invalid and could not be read back. Render from hour/minute/second/microsecond only; naive times are unaffected.
@Master-Norna
Master-Norna force-pushed the fix/time-tzinfo-serialization branch from 9597354 to dc2cc45 Compare September 30, 2026 01:24
@Master-Norna

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master — the conflict was with the fold argument in #620, which now coexists with the _format_time rendering. Full suite passes locally (1064) and CI is green. Thanks!

@frostming
frostming merged commit ce8f8ee into python-poetry:master Sep 30, 2026
25 checks passed
@frostming frostming removed the pending merge This PR is okay to merge but needs extra actions label Sep 30, 2026
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