Skip to content

Bug in datetime lib causes incorrect timedelta value #128765

@oldwizard1010

Description

@oldwizard1010

Bug report

Bug description:

Problem with datetime lib

# Add a code block here, if required
import time
from datetime import datetime

x1 = (datetime.fromisoformat('2025-01-08T00:00:01') - datetime.utcnow()).seconds
time.sleep(5)
x2 = (datetime.fromisoformat('2025-01-08T00:00:01') - datetime.utcnow()).seconds
print(f"x1 should be less than x2, but x1={x1}, x2={x2}; x1<x2={x1<x2}")

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directory

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions