[][src]Function event_parser::to_event

pub fn to_event(text: &str) -> Event

Parses text into an Event in VEVENT format (RFC 5545, Section 3.6.1 ).

Arguments

  • text - A string slice that holds the the text to be parsed.

Example

use event_parser::to_event;
use chrono::{DateTime, Utc, offset, prelude, NaiveDate};
use icalendar::{Component, Event};
 

let event = to_event("Summer Camp 6/1-6/8");
let expected_event = Event::new()
    .summary("Dinner")
    .starts(DateTime::<Utc>::from_utc(NaiveDate::from_ymd(2020, 6, 1).and_hms(0, 0, 0), Utc))
    .ends(DateTime::<Utc>::from_utc(NaiveDate::from_ymd(2020, 6, 8).and_hms(0, 0, 0), Utc))
    .done();
assert!(equal(event, expected_event));