Skip to main content

ics_core/
lib.rs

1//! Typed iCalendar (RFC 5545) model with vendor-extension support.
2//!
3//! Scope today (ADR-017 Migration Step 3): minimal `VEvent` typed model,
4//! flat parser, formatter, and helpers. The vendor-extension model from
5//! ADR-001 (per-vendor profile bundles + `RawProperty` fallback) and the
6//! typed `Error` from ADR-019 land in subsequent migration steps.
7
8pub mod calendar;
9pub mod error;
10pub mod event;
11pub mod parser;
12pub mod profile;
13pub mod query;
14pub mod raw;
15pub mod vcalendar;
16
17pub use calendar::{format_calendar, format_vevent};
18pub use error::{Error, Result};
19pub use event::{EventClass, Transp, VEvent};
20pub use parser::{parse_calendar, parse_indices};
21pub use profile::{google, icloud, microsoft};
22pub use query::{SortKey, remove_event_by_summary, remove_events_by_indices, sort_events};
23pub use raw::{RawComponent, RawProperty};
24pub use vcalendar::VCalendar;
25
26#[cfg(test)]
27pub(crate) mod test_helpers {
28    use crate::event::VEvent;
29    use chrono::{NaiveDate, NaiveDateTime};
30
31    pub(crate) fn test_dtstamp() -> NaiveDateTime {
32        NaiveDate::from_ymd_opt(2026, 3, 27)
33            .unwrap()
34            .and_hms_opt(0, 0, 0)
35            .unwrap()
36    }
37
38    pub(crate) fn make_event(
39        uid: &str,
40        start: (i32, u32, u32),
41        end: (i32, u32, u32),
42        summary: &str,
43    ) -> VEvent {
44        VEvent {
45            uid: uid.to_string(),
46            dtstamp: test_dtstamp(),
47            dtstart: NaiveDate::from_ymd_opt(start.0, start.1, start.2).unwrap(),
48            dtend: NaiveDate::from_ymd_opt(end.0, end.1, end.2).unwrap(),
49            summary: summary.to_string(),
50            transp: None,
51            class: None,
52            categories: vec![],
53            microsoft: None,
54            google: None,
55            icloud: None,
56            unknown: vec![],
57            unrecognized_components: vec![],
58        }
59    }
60}