diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-01-20 00:33:05 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-01-20 00:33:05 +0100 |
commit | c73049fb0a3b780ed70c7156f456883191d79cb2 (patch) | |
tree | b0a56e95007d460e8cdc55b865e7fe62c6a381a5 /src/icalwrap | |
parent | 1afdd3ce0d929a7ba401363c8e6be518554446de (diff) |
icalvcalendar: add with_* methods for dtstart, dtend, location and summary
Diffstat (limited to 'src/icalwrap')
-rw-r--r-- | src/icalwrap/icalvcalendar.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs index fdbdb0f..68ea4ed 100644 --- a/src/icalwrap/icalvcalendar.rs +++ b/src/icalwrap/icalvcalendar.rs @@ -8,7 +8,6 @@ use super::IcalVEvent; use super::IcalComponent; use super::IcalTime; use ical; -use utils::dateutil; pub struct IcalVCalendar { comp: Rc<IcalComponentOwner>, @@ -138,6 +137,42 @@ impl IcalVCalendar { self } + pub fn with_dtstart(self, dtstart: &DateTime<Local>) -> Self { + let event = self.get_principal_event(); + unsafe { + let dtstart_icaltime = IcalTime::from(dtstart); + ical::icalcomponent_set_dtstart(event.get_ptr(), *dtstart_icaltime); + } + self + } + + pub fn with_dtend(self, dtend: &DateTime<Local>) -> Self { + let event = self.get_principal_event(); + unsafe { + let dtend_icaltime = IcalTime::from(dtend); + ical::icalcomponent_set_dtend(event.get_ptr(), *dtend_icaltime); + } + self + } + + pub fn with_location(self, location: &str) -> Self { + let event = self.get_principal_event(); + unsafe { + let c_str = CString::new(location).unwrap(); + ical::icalcomponent_set_location(event.get_ptr(), c_str.as_ptr()); + } + self + } + + pub fn with_summary(self, summary: &str) -> Self { + let event = self.get_principal_event(); + unsafe { + let c_str = CString::new(summary).unwrap(); + ical::icalcomponent_set_summary(event.get_ptr(), c_str.as_ptr()); + } + self + } + pub fn with_last_modified_now(self) -> Self { let event = self.get_principal_event(); unsafe { |