#ical #calendar #properties #rfc5545 #events #specification #rfc7986

ics

A library for creating iCalendar files as specified in RFC5545 and RFC7986

20 releases

0.5.8 Sep 25, 2022
0.5.7 Aug 11, 2021
0.5.6 Jul 30, 2021
0.5.5 Nov 28, 2020
0.2.2 Nov 3, 2018

#27 in Date and time

Download history 500/week @ 2023-12-11 404/week @ 2023-12-18 213/week @ 2023-12-25 456/week @ 2024-01-01 421/week @ 2024-01-08 715/week @ 2024-01-15 522/week @ 2024-01-22 503/week @ 2024-01-29 495/week @ 2024-02-05 514/week @ 2024-02-12 538/week @ 2024-02-19 599/week @ 2024-02-26 710/week @ 2024-03-04 771/week @ 2024-03-11 678/week @ 2024-03-18 588/week @ 2024-03-25

2,787 downloads per month
Used in 7 crates

MIT/Apache

69KB
1.5K SLoC

Crates.io Crates.io Build Status Documentation

A library for creating iCalendar files as specified in RFC5545 and RFC7986.

Minimum supported rustc

1.26.0+

This version is officially supported and tested in CI. Changes to the minimum supported version will be noted in the Changelog.

Installation

To use this library add the library as a dependency in your Cargo.toml:

[dependencies]
ics = "0.5"

Optionally you can disable default features.

[dependencies.ics]
version = "0.5"
default-features = false

Features

  • rfc7986 (enabled by default): adds properties from the newer specification

Usage

use ics::properties::{Categories, Description, DtEnd, DtStart, Organizer, Status, Summary};
use ics::{escape_text, Event, ICalendar};

fn main() -> std::io::Result<()> {
    // create new iCalendar object
    let mut calendar = ICalendar::new("2.0", "-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN");

    // create event which contains the information regarding the conference
    let mut event = Event::new("b68378cf-872d-44f1-9703-5e3725c56e71", "19960704T120000Z");
    // add properties
    event.push(Organizer::new("mailto:jsmith@example.com"));
    event.push(DtStart::new("19960918T143000Z"));
    event.push(DtEnd::new("19960920T220000Z"));
    event.push(Status::confirmed());
    event.push(Categories::new("CONFERENCE"));
    event.push(Summary::new("Networld+Interop Conference"));
    // Values that are "TEXT" must be escaped (only if the text contains a comma,
    // semicolon, backslash or newline).
    event.push(Description::new(escape_text(
        "Networld+Interop Conference and Exhibit\n\
         Atlanta World Congress Center\n\
         Atlanta, Georgia"
    )));
    // add event to calendar
    calendar.add_event(event);

    // write calendar to file
    calendar.save_file("event.ics")?;
    Ok(())

    /* inside event.ics
    BEGIN:VCALENDAR
    VERSION:2.0
    PRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN
    BEGIN:VEVENT
    UID:b68378cf-872d-44f1-9703-5e3725c56e71
    DTSTAMP:19960704T120000Z
    ORGANIZER:mailto:jsmith@example.com
    DTSTART:19960918T143000Z
    DTEND:19960920T220000Z
    STATUS:CONFIRMED
    CATEGORIES:CONFERENCE
    SUMMARY:Networld+Interop Conference
    DESCRIPTION:Networld+Interop Conference and Exhibit
    Atlanta World Congress
     Center
    Atlanta\, Georgia
    END:VEVENT
    END:VCALENDAR
    */
}

License

Licensed under either of

at your option.

Contribution

Contributions are always welcome! Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps

Features