Crate dateless[][src]

Dateless

Dateless is an events & calendar library for Rust.

Usage

First, add dateless as a dependency in your project’s Cargo.toml:

[dependencies]
dateless = "0.3.1"

And then, you can start with creating a calendar:

use dateless::prelude::*;

fn main() {
    let mut calendar = Calendar::new();
}

Now, let’s create an Event and assign it to the newly created Calendar instance. It can be done simply with EventPartial:

use dateless::prelude::*;
use chrono::Utc;

fn main() {
    let mut calendar = Calendar::new();

    let event = EventPartial::new(String::from("Anne's birthday"))
        .whole_day(Utc::today())
        .daily()
        .complete();

    calendar.add_event(event);
}

Above, 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.

Finally, we can check a specific day for occurrences of events.

use dateless::prelude::*;
use chrono::{Utc, Duration};

fn main() {
    let mut calendar = Calendar::new();

    let event = EventPartial::new(String::from("Anne's birthday"))
        .whole_day(Utc::today())
        .daily()
        .complete();

    calendar.add_event(event);

    let seven_days_later = Utc::today() + Duration::days(7);

    println!("{:#?}", calendar.day(seven_days_later));
}

It prints to stdout:

[
    EventOccurrence {
        name: "Anne's birthday",
        description: None,
        period: WholeDays(
            2021-05-08Z,
            2021-05-08Z,
        ),
    },
]

Modules

prelude

Macros

bind_partial_filler
bind_partial_filler_boxed
bind_partial_filler_default
bind_partial_trait_filler

Structs

Calendar
Event
EventOccurrence
EventPartial

Traits

Cyclicity
Period