eventix/
lib.rs

1//! # eventix
2//!
3//! A high-level calendar and recurrence library for Rust with timezone-aware scheduling,
4//! exceptions, and ICS import/export capabilities.
5//!
6//! ## Features
7//!
8//! - **Timezone-aware events**: All date/time fields use `chrono` with `chrono-tz` for proper timezone handling
9//! - **Recurrence rules**: Support for daily, weekly, monthly, and yearly recurrence patterns
10//! - **Exceptions**: Skip specific dates or apply custom filters (e.g., skip weekends)
11//! - **ICS support**: Import and export events using the iCalendar format (RFC 5545 compliant with TZID support)
12//! - **Builder API**: Ergonomic, fluent interface for creating events and calendars
13//! - **Gap validation**: Find gaps between events, detect conflicts, and analyze schedule density
14//! - **Schedule analysis**: Unique features for occupancy metrics, availability finding, and conflict resolution
15//!
16//! ## Quick Start
17//!
18//! ```rust
19//! use eventix::{Calendar, Event, Recurrence};
20//!
21//! let mut cal = Calendar::new("My Calendar");
22//!
23//! let event = Event::builder()
24//!     .title("Weekly Team Meeting")
25//!     .description("Discuss project progress")
26//!     .start("2025-11-01 10:00:00", "America/New_York")
27//!     .duration_hours(1)
28//!     .recurrence(Recurrence::weekly().count(10))
29//!     .build()
30//!     .expect("Failed to build event");
31//!
32//! cal.add_event(event);
33//! ```
34//!
35//! ## Timezone-Aware ICS Export
36//!
37//! Events are exported with proper timezone information for compatibility with calendar applications:
38//!
39//! ```rust
40//! use eventix::{Calendar, Event};
41//!
42//! let mut cal = Calendar::new("Work Schedule");
43//!
44//! // Non-UTC timezones include TZID parameter
45//! let event = Event::builder()
46//!     .title("Team Meeting")
47//!     .start("2025-10-27 10:00:00", "America/New_York")
48//!     .duration_hours(1)
49//!     .build()
50//!     .unwrap();
51//!
52//! cal.add_event(event);
53//! cal.export_to_ics("schedule.ics").unwrap();
54//!
55//! // Generates: DTSTART;TZID=America/New_York:20251027T100000
56//! // Compatible with Google Calendar, Outlook, and Apple Calendar
57//! ```
58//!
59//! ## Schedule Analysis (Unique Feature)
60//!
61//! Find gaps, detect conflicts, and analyze schedule density:
62//!
63//! ```rust
64//! use eventix::{Calendar, Event, gap_validation, timezone, Duration};
65//!
66//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
67//! let mut cal = Calendar::new("Work Schedule");
68//!
69//! // Add some events...
70//! let event1 = Event::builder()
71//!     .title("Morning Meeting")
72//!     .start("2025-11-03 09:00:00", "America/New_York")
73//!     .duration_hours(1)
74//!     .build()?;
75//!
76//! let event2 = Event::builder()
77//!     .title("Afternoon Call")
78//!     .start("2025-11-03 14:00:00", "America/New_York")
79//!     .duration_hours(1)
80//!     .build()?;
81//!
82//! cal.add_event(event1);
83//! cal.add_event(event2);
84//!
85//! // Find gaps in schedule
86//! let tz = timezone::parse_timezone("America/New_York")?;
87//! let start = timezone::parse_datetime_with_tz("2025-11-03 08:00:00", tz)?;
88//! let end = timezone::parse_datetime_with_tz("2025-11-03 18:00:00", tz)?;
89//!
90//! let gaps = gap_validation::find_gaps(&cal, start, end, Duration::minutes(30))?;
91//! println!("Found {} gaps of at least 30 minutes", gaps.len());
92//!
93//! // Calculate schedule density
94//! let density = gap_validation::calculate_density(&cal, start, end)?;
95//! println!("Schedule occupancy: {:.1}%", density.occupancy_percentage);
96//! # Ok(())
97//! # }
98//! ```
99//!
100//! ## Modules
101//!
102//! - [`calendar`] - Calendar container for managing collections of events
103//! - [`event`] - Event types and builder API
104//! - [`gap_validation`] - Schedule analysis, gap detection, and conflict resolution (unique feature)
105//! - [`ics`] - ICS (iCalendar) import/export with TZID support
106//! - [`recurrence`] - Recurrence patterns (daily, weekly, monthly, yearly)
107//! - [`timezone`] - Timezone utilities with DST awareness
108//!
109//! ## Examples
110//!
111//! See the `examples/` directory for more comprehensive examples:
112//! - `basic.rs` - Simple calendar creation and event management
113//! - `recurrence.rs` - Daily, weekly, monthly, and yearly recurrence patterns
114//! - `ics_export.rs` - ICS import/export functionality
115//! - `timezone_ics_export.rs` - Timezone-aware ICS export demonstration
116//! - `gap_validation.rs` - Schedule analysis and gap detection features
117
118pub mod calendar;
119pub mod event;
120pub mod gap_validation;
121pub mod ics;
122pub mod recurrence;
123pub mod timezone;
124
125mod error;
126
127pub use calendar::Calendar;
128pub use error::{EventixError, Result};
129pub use event::{Event, EventBuilder, EventStatus};
130pub use recurrence::Recurrence;
131
132// Re-export commonly used types
133pub use chrono::{DateTime, Duration, NaiveDateTime};
134pub use chrono_tz::Tz;