Skip to content

fix: preserve aware datetime instants during UTC serialization - #981

Draft
Kayvan-Zahiri wants to merge 1 commit into
twilio:mainfrom
Kayvan-Zahiri:codex/serialize-aware-datetimes-in-utc
Draft

Kayvan-Zahiri wants to merge 1 commit into
twilio:mainfrom
Kayvan-Zahiri:codex/serialize-aware-datetimes-in-utc

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Fixes #980

The shared handwritten ISO8601 datetime serializer currently discards UTC offsets while appending Z. For example, a scheduled-message send_at of 2030-01-02 01:30+05:30 becomes 2030-01-02T01:30:00Z, shifting the requested instant by 5.5 hours.

Convert aware datetimes to UTC before formatting. Keep the existing naive/date/string/unset behavior. Document the conversion in the serializer and add six tests through the public Client.messages.create API using a mocked HTTP transport, including positive/negative offsets across date boundaries and four compatibility controls. No generated REST files are changed.

Validation: two regressions fail before the fix and four controls pass. Full required make test passes on Python3.12:647 tests, source/test Flake8, Autoflake, and Black (797 files). No live Twilio requests/messages or full Python matrix run. AI-assisted contribution; maintainer review pending.

Checklist

  • Contributions are made under the project's MIT license.
  • Material functionality and test change.
  • Read and followed the Contribution Guidelines.
  • PR title follows the required format.
  • Based on the current main checkout.
  • Added tests proving the fix.
  • Added appropriate inline documentation; no new public API requires separate Markdown documentation.

This branch has not been deployed

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

Aware datetime serialization changes scheduled-message instants by ignoring UTC offsets

1 participant