Skip to content

timedelta #131698

@Applied-AI-JK

Description

@Applied-AI-JK

Bug report

Bug description:

Does timdelta work only positive value ?

sd1 is just 1 min faster than sd2

result of sd1 - sd2 is 86340 in second
sd2 - sd1 is 60 second

here is sample code
Version is Python 3.13 on Windows

'``python
import datetime

sd1 = '250323 0933'
sd2 = '25/03/23 09:34'
d1 = datetime.datetime.strptime(sd1, '%y%m%d %H%M')
d2 = datetime.datetime.strptime(sd2, '%y/%m/%d %H:%M')

print(f"d1: {d1} \nd2: {d2} \nd1-d2: {d1-d2} {(d1-d2).seconds} \nd2-d1: {d2-d1} {(d2-d1).seconds}")


Result:s
d1: 2025-03-23 09:33:00
d2: 2025-03-23 09:34:00
d1-d2: -1 day, 23:59:00 86340
d2-d1: 0:01:00 60




### CPython versions tested on:

3.13

### Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions