Skip to content

timedelta fails to consider fold #112638

Description

@uranusjr

Bug report

Bug description:

fromdatetimeimportdatetimefromzoneinfoimportZoneInfo# DST ends at 3am, folding back to 2.z=ZoneInfo('Europe/Zurich')
# The fold zone.d0=datetime(2023, 10, 29, 2, 30, fold=0, tzinfo=z)
d1=datetime(2023, 10, 29, 2, 30, fold=1, tzinfo=z)
# This should be out of DST.d2=datetime(2023, 10, 29, 3, tzinfo=z)
# These are correct.print(d2.timestamp() -d0.timestamp()) # 5400.0print(d2.timestamp() -d1.timestamp()) # 1800.0# These are not.print(d2-d0) # datetime.timedelta(seconds=1800)print(d2-d1) # datetime.timedelta(seconds=1800)

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions