Skip to content

rrule generated creates datetimes with non-existent local time (i.e., not respecting DST gaps) #1425

Description

@BurntSushi

Given this program:

from datetime import datetime

from dateutil import tz
from dateutil.rrule import DAILY, rrule

tzinfo = tz.tz.gettz('America/New_York')
dt = datetime(2025, 3, 7, 2, 30, 0, tzinfo=tzinfo)
for dt in rrule(DAILY, dtstart=dt, count=5):
    print(dt)

Running it like so produces this output:

$ uv run --with python-dateutil mre.py
2025-03-07 02:30:00-05:00
2025-03-08 02:30:00-05:00
2025-03-09 02:30:00-04:00
2025-03-10 02:30:00-04:00
2025-03-11 02:30:00-04:00

But 2025-03-09 02:30:00-04:00 is not a valid datetime for America/New_York, since that's when the East coast entered DST.

RFC 5545 seems to require that these datetimes are totally ignored:

Recurrence rules may generate recurrence instances with an invalid date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM on a day where the local time is moved forward by an hour at 1:00 AM). Such recurrence instances MUST be ignored and MUST NOT be counted as part of the recurrence set.

So I think I'd expect this as output:

2025-03-07 02:30:00-05:00
2025-03-08 02:30:00-05:00
2025-03-10 02:30:00-04:00
2025-03-11 02:30:00-04:00
2025-03-12 02:30:00-04:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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