ical_rust ๐
ical_rust is a lightweight, efficient, and robust Rust library for parsing iCalendar (.ics) files and dynamically expanding recurring events. It simplifies scheduling logic by fully evaluating complex recurrence rules (RRULE) and exclusion dates (EXDATE) to calculate concrete event occurrences.
๐ Features
- iCalendar Parser: Robust parsing of
.icsfile streams, automatically handling folded lines and block structures. - Recurrence Expansion: Comprehensive support for recurring events (
RRULE), supportingYEARLY,MONTHLY,WEEKLY, andDAILYfrequencies, intervals, count limiters, until dates, specific weekdays (BYDAY), and day of month (BYMONTHDAY). - Exclusion Dates (
EXDATE): Supports exclusion lists to accurately skip specified recurrence dates. - Timezone Integration: High-fidelity timezone management backed by the robust
chronoandchrono-tzlibraries. - Collision & Overlap Queries: Evaluate active events or find next occurrences with simple APIs.
๐ ๏ธ Quick Start
Here is a simple example showing how to parse an iCalendar string, access an event, and expand its recurring occurrences:
use ;
๐ Core Architecture
VCalendar
The main entrance point and container for parsed iCalendar information. It manages parsed VTimezone collections and lists of VEvent records.
- Implementations of
TryFrom<&str>allow direct instantiation from file-read contents.
VEvent
Represents an individual event block (VEVENT). Contains standard properties:
dt_start/dt_end: Event lifetime boundaries asDateOrDateTime.summary/description: Metadata explaining the event.rrule: Optional recurrence rules.exdates: Optional list of excluded date-times.
You can query individual events using:
into_iter(): Returns aVEventIteratorthat generates each concrete recurrence instance of the event as aRange<DateOrDateTime>.next_occurrence_since(dt): Finds the next occurrence of the event that is active or starts after a specified time.
DateOrDateTime
A custom enum handling both single full-day bounds and precise timezone-associated date-times:
DateOrDateTime::WholeDay(DateTime<Utc>)DateOrDateTime::DateTime(DateTime<Utc>)
Provides support for calculations, incrementing components safely (e.g. leap years, variable-length months), and testing for intersection overlapping (intersects).
๐งช Running Tests
The library contains a robust test suite covering edge cases in timezone calculation, rule iteration, and parser syntax. You can run them locally using:
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.