You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incrementing by day fails for timezones like Chile/Continental where spring forward occurs at midnight. Works for Europe. #915
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
just to be super clear: the 'bug' for me here is not that we land at 1am chilean time on 07.09.2025. This is actually great and exactly what I would expect from an (otherwise awesome) time-handling library. I added one day from midnight on the 6th and I got the start of the next day, no problem. Great infact, thanks! BUT what sucks is that when I then add one day I do not get to the start of the next day. So pendulum is clever enough to work out that the start of spring-forward day is 1am (midnight in this timezone simply does not exist) yay! but nay! one 'day' afterwards is not just 24 hours later so the cleverness is lost.
Activity
quoth-le-corbeau commentedon Aug 28, 2025
just to be super clear: the 'bug' for me here is not that we land at 1am chilean time on 07.09.2025. This is actually great and exactly what I would expect from an (otherwise awesome) time-handling library. I added one day from midnight on the 6th and I got the start of the next day, no problem. Great infact, thanks! BUT what sucks is that when I then add one day I do not get to the start of the next day. So pendulum is clever enough to work out that the start of spring-forward day is 1am (midnight in this timezone simply does not exist) yay! but nay! one 'day' afterwards is not just 24 hours later so the cleverness is lost.