Skip to content

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

Open
Master-Norna wants to merge 1 commit into
python-poetry:masterfrom
Master-Norna:fix/time-tzinfo-serialization
Open

Master-Norna wants to merge 1 commit into
python-poetry:masterfrom
Master-Norna:fix/time-tzinfo-serialization

Conversation

@Master-Norna

Copy link
Copy Markdown

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).

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.
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.

1 participant