Skip to content

Incrementing by day fails for timezones like Chile/Continental where spring forward occurs at midnight. Works for Europe. #915

@quoth-le-corbeau

Description

@quoth-le-corbeau
import pendulum

# pendulum==3.0.0
# Python 3.10.7

# Step 1 : start the day before spring forward dst day
>>> dt = pendulum.datetime(2025, 9, 6, 0, 0, tz="Chile/Continental")
>>> print("Start:", dt)
Start: 2025-09-06 00:00:00-04:00

>>> print(dt.add(days=1))
2025-09-07 01:00:00-03:00 # since no midnight in chilean tz

# Step 2: Add 1 day and normalize to start_of_day
>>> dt_plus1 = dt.add(days=1).start_of("day")
>>> print("After 1 day:", dt_plus1)
After 1 day: 2025-09-06 23:00:00-04:00

# Step 3: Check if it's truly start of day
>>> print("Is start of day?", dt_plus1 == dt_plus1.start_of("day"))
Is start of day? False

# Step 4: Add another day and normalize again
>>> dt_plus2 = dt_plus1.add(days=1).start_of("day")
>>> print("After 2 days:", dt_plus2)
After 2 days: 2025-09-07 01:00:00-03:00

# BUT Same concept works for CET correctly 

# Step 1: Start one day before spring forward day (but spring forward at 2am not midnight!)
>>> dt = pendulum.datetime(2025, 3, 29, 0, 0, tz="Europe/Vienna")
>>> print("Start:", dt)
Start: 2025-03-29 00:00:00+01:00

>>> print(dt.add(days=1))
2025-03-30 00:00:00+01:00

# Step 2: Add 1 day and normalize to start_of_day
>>> dt_plus1 = dt.add(days=1).start_of("day")
>>> print("After 1 day:", dt_plus1)
After 1 day: 2025-03-30 00:00:00+01:00

# Step 3: Check if it's truly start of day
>>> print("Is start of day?", dt_plus1 == dt_plus1.start_of("day"))
Is start of day? True

# Step 4: Add another day and normalize again
>>> dt_plus2 = dt_plus1.add(days=1).start_of("day")
>>> print("After 2 days:", dt_plus2)
After 2 days: 2025-03-31 00:00:00+02:00

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