Skip to content

RecurrenceId.to_value does not allow for parsing recurrence_id with TZID param #480

@rhofland

Description

@rhofland

Describe the bug
RecurrenceId.to_value does not allow for parsing recurrence_id with TZID param. This causes issue in the store.edit as no items can be matched.

To Reproduce

from ical.types import RecurrenceId

recurrence_id_date_str  = '20250511'
print(RecurrenceId.to_value(recurrence_id=recurrence_id_date_str))

recurrence_id_naive_datetime_str  = '20250511T020000'
print(RecurrenceId.to_value(recurrence_id=recurrence_id_naive_datetime_str))

recurrence_id_utc_datetime_str = '20250511T020000Z'
print(RecurrenceId.to_value(recurrence_id=recurrence_id_utc_datetime_str))

recurrence_id_ny_datetime_str = 'TZID=America/New_York:20250511T020000'
print(RecurrenceId.to_value(recurrence_id=recurrence_id_ny_datetime_str))


Output

2025-05-11
2025-05-11 02:00:00
2025-05-11 02:00:00+00:00
Traceback (most recent call last):
  File "/home/hofsol/src/test.py", line 13, in <module>
    print(RecurrenceId.to_value(recurrence_id=recurrence_id_ny_datetime_str))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/ical/types/recur.py", line 168, in to_value
    raise ValueError(f"Unable to parse date/time value: {errors}")
ValueError: Unable to parse date/time value: [ValueError("Expected value to match DATE pattern: 'TZID=America/New_York:20250511T020000'"), ValueError('Expected value to match DATE-TIME pattern: TZID=America/New_York:20250511T020000')]

Expected behavior

2025-05-11
2025-05-11 02:00:00
2025-05-11 02:00:00+00:00
2025-05-11 02:00:00-04:00

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions