dateless/lib.rs
1#![doc(html_logo_url = "https://cdn.v-sn.io/dateless-logo")]
2
3/*!
4
5# Dateless
6
7Dateless is an events & calendar library for Rust.
8
9## Usage
10
11First, add `dateless` as a dependency in your project's Cargo.toml:
12
13```toml
14[dependencies]
15dateless = "0.3.1"
16```
17
18And then, you can start with creating a calendar:
19
20```rust
21use dateless::prelude::*;
22
23fn main() {
24 let mut calendar = Calendar::new();
25}
26```
27
28Now, let's create an `Event` and assign it to the newly created `Calendar` instance. It can be done simply with `EventPartial`:
29
30```rust
31use dateless::prelude::*;
32use chrono::Utc;
33
34fn main() {
35 let mut calendar = Calendar::new();
36
37 let event = EventPartial::new(String::from("Anne's birthday"))
38 .whole_day(Utc::today())
39 .daily()
40 .complete();
41
42 calendar.add_event(event);
43}
44```
45
46Above, we created a new `Event` called "Anne's birthday" lasting all day today and set it to be recurring every week. In the last line we assigned the event to `calendar`.
47
48Finally, we can check a specific day for occurrences of events.
49
50
51```rust
52use dateless::prelude::*;
53use chrono::{Utc, Duration};
54
55fn main() {
56 let mut calendar = Calendar::new();
57
58 let event = EventPartial::new(String::from("Anne's birthday"))
59 .whole_day(Utc::today())
60 .daily()
61 .complete();
62
63 calendar.add_event(event);
64
65 let seven_days_later = Utc::today() + Duration::days(7);
66
67 println!("{:#?}", calendar.day(seven_days_later));
68}
69```
70
71It prints to `stdout`:
72
73```json
74[
75 EventOccurrence {
76 name: "Anne's birthday",
77 description: None,
78 period: WholeDays(
79 2021-05-08Z,
80 2021-05-08Z,
81 ),
82 },
83]
84```
85
86*/
87
88#[macro_use]
89mod codegen;
90
91mod calendar;
92mod chrono;
93mod event;
94pub mod prelude;
95
96#[cfg(test)]
97mod test;
98
99#[cfg(feature = "serde_support")]
100mod serde;
101
102pub use calendar::Calendar;
103pub use event::{Cyclicity, Event, EventOccurrence, EventPartial, Period};