Skip to content

Preserve explicit UTC when parsing ISO 8601 timestamps - #2255

Open
khushalx wants to merge 1 commit into
apache:trunkfrom
khushalx:codex/iso8601-explicit-utc
Open

khushalx wants to merge 1 commit into
apache:trunkfrom
khushalx:codex/iso8601-explicit-utc

Conversation

@khushalx

@khushalx khushalx commented Dec 1, 2026

Copy link
Copy Markdown

Description

Fixes #2254.

parse_date("2026-12-01T12:34:56Z", default_timezone=FixedOffset(5, 30, "+05:30")) currently returns a +05:30 timestamp. With default_timezone=None, it drops timezone information altogether. An explicit Z must mean UTC; the fallback is only for input with no zone.

Return UTC for Z in parse_timezone. Regression tests cover positive, negative and None defaults through both the timezone helper and date parser, plus unchanged fallback and numeric-offset behavior. Three subcases fail before the fix.

This is independent of #2243 and #2245: it changes only the explicit-UTC branch, leaving fraction parsing and optional fields alone.

Status

Done, ready for review.

Checklist

  • Code linting: pre-commit checks passed on Python 3.12.
  • Documentation: changelog entry added.
  • Tests: utility tests passed (30 tests and 5 subtests). Full suite: 7,066 passed, 17 skipped, 98 subtests passed; one environment-dependent failure described below.
  • ICLA not required for this small bug fix.

AI assistance: Codex (GPT-6) reproduced the bug, implemented and reviewed the fix, and ran validation. No human review before posting.

Validation note: BaseConnectionClassTestCase.test_connection_timeout_raised expects a connect timeout from 10.255.255.1, but this machine receives a read timeout or connection reset instead. The same test fails on an untouched origin/trunk worktree. The change does not touch connection handling.

Apply the default timezone only when the timestamp has no timezone, including when the default is None.

Fixes apache#2254

Assisted-by: Codex:GPT-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant