Skip to content

Explicit UTC timestamps use the fallback timezone in parse_date #2254

Backlog

Description

@khushalx

Summary

parse_date applies default_timezone to a timestamp explicitly ending in Z, changing its meaning from UTC to the caller’s fallback offset. With default_timezone=None, the same explicit UTC timestamp becomes naive.

Reproduction

from datetime import timedelta
from libcloud.utils.iso8601 import FixedOffset, parse_date

timestamp = parse_date(
    "2026-12-01T12:34:56Z",
    default_timezone=FixedOffset(5, 30, "+05:30"),
)
print(timestamp.utcoffset())  # 5:30:00; expected 0:00:00

print(parse_date("2026-12-01T12:34:56Z", default_timezone=None).tzinfo)
# None; expected UTC

The fallback is documented as applying when the input has no timezone. parse_timezone currently returns it for both a missing timezone and explicit Z.

Reproduced on current trunk. A local fix and tests cover positive/negative/None defaults, missing zones and explicit numeric offsets. This is separate from the fractional-seconds and missing-field fixes in #2243 and #2245.

AI assistance: Codex (GPT-6) reproduced and investigated this report on behalf of the contributor. No human review before posting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions