diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | README.md | 73 | ||||
-rw-r--r-- | example.rs | 44 | ||||
-rw-r--r-- | src/lib.rs | 6 |
5 files changed, 132 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4f917d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target +Cargo.lock +*.swp diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c5641fa --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "icalendar" +version = "0.1.0" +authors = ["Hendrik Sollich <hendrik@hoodie.de>"] + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..369dee1 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# iCalendar in Rust + +This is still just an early idea, there is nothing implemented, +I haven't even read the completely [spec](http://tools.ietf.org/html/rfc5545) yet. + +I'd love to create iCal files with a very [diesel](https://diesel.rs/) or [active support](https://github.com/wycats/rust-activesupport) like syntax. + +```rust +fn main(){ + + use Repeats::*; + let important_meeting + .start_date(chrono::Date::new("2016.05.09")) + .repeats(BiWeekly); + + let important_meeting + .start_date(chrono::Date::new("2016.05.09")) + .every(7.days()); + + let birthday = Event::new() + .start_date(chrono::Date::new("1987.03.15")) + .repeats(Annually); + + let birthday = Event::new() + .every(15.march()); + + let xmas = Event::every(24.december()); + + + use Month::*; + let sysadminday = Event::every(Last.friday().of(July)); + + let tdo = Todo::new("buy milk"); + + let tdo = Alarm::new("get up").at("05:30").every(Thursday); + let tdo = Alarm::new("get up").at("06:00").on(Fridays); + + let dont_disturb = Busy::between("09.05.2016").and("12.05.2016"); + let dont_disturb = Busy::between("09..12").am().on(Mondays); + + let dear_diary = Journal::from_description("Dear Diary\nToday my cat ran away. Now I'm sad"); + + let brush_teeth = Alarm::new("Brush Your Teeth").twice().every(Day); + + let event = Event::new("this is a summary") + .start_date(chrono::Date()) + .end_date(chrono::Date()) + .description("This property provides a more complete description of the + calendar component than that provided by the \"SUMMARY\" property.") + .attendee("mailto:john.doe@example.com") + .attendee(Attendee::new("jane.doe@hoodie.de").has_declined()) + .attendee(Attendee::new("jane.doe@hoodie.de").has_accepted()) + .trigger("-PT15M") + .repeats_every(Repeats::First.wednesday()) + .ip_class(IpClass::Private) + ; + +} +``` + +# Steps + +1. flesh out an api +2. implement types and datastructures +3. implement serialization +4. find some way to test it + + + +Perhaps you can already use [vobject](http://rust-vobject.unterwaditzer.net/vobject/) to parse iCalendar files. +I need to test this still. + + diff --git a/example.rs b/example.rs new file mode 100644 index 0000000..7c1e358 --- /dev/null +++ b/example.rs @@ -0,0 +1,44 @@ + +extern crate icalendar; +use icalendar::Event; +use icalendar::every; + +fn main(){ + let event = Event::new() + .start_date(chrono::Date()); + .end_date(chrono::Date()); + .summary(Some(String)) + .description(Some(String)) + .attendee("mailto:john.doe@example.com") + .attendee(Attendee::new("jane.doe@hoodie.de").has_declined()) + .attendee(Attendee::new("jane.doe@hoodie.de").has_accepted()) + .trigger("-PT15M") + .repeats_every(15.days()) + .repeats_every(Repeats::First.wednesday()) + .repeats_every(Repeats::Last.friday().in(Month::June)) + .busy(between("09.05.2016").an("12.05.2016") ) + .ip_class(IpClass::Private) + ; +} + +// BEGIN:VCALENDAR +// VERSION:2.0 +// PRODID:icalendar-rust +// CALSCALE:GREGORIAN +// +// BEGIN:VEVENT +// DTSTAMP:20160507T120700Z +// UID:6e184fba-6e9a-484f-8b47-384f771276c4 +// DTSTART;VALUE=DATE:20121210 +// DTEND;VALUE=DATE:20121211 +// DESCRIPTION:Verantwortung: Frank Hedecke\n +// SUMMARY:Weihnachtsfeier +// END:VEVENT +// +// BEGIN:VEVENT +// DTSTAMP:20160507T120700Z +// UID:bc8b15ec-fa3d-4b1d-811f-4a7277755122 +// DTSTART;VALUE=DATE:20130120 +// DTEND;VALUE=DATE:20130121 +// DESCRIPTION:Verantwortung: Hendrik Sollich\n +// END:VEVENT diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..cdfbe1a --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,6 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + } +} |