Skip to content

Conversion to UTC wrong in pytz 2024.2  #130

@aquamatthias

Description

@aquamatthias

Hi,

I have this test code which started to fail with the latest release of pytz:

assert utc_str(datetime(2020, 1, 1, 0, 0, 0, 0, tzinfo=pytz.timezone("GMT"))) == "2020-01-01T00:00:00Z"

and fails with this error:

E       AssertionError: assert '2019-12-31T23:42:00Z' == '2019-12-31T23:00:00Z'

The utc_str function boils down to:

def utc_str(dt: datetime) -> str:
    return dt.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

It works as expected in pytz 2024.1.
Am I doing something wrong?

Thanks for clarification!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions