Skip to main content

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