aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/events.rs6
-rw-r--r--src/periodic.rs11
2 files changed, 13 insertions, 4 deletions
diff --git a/src/events.rs b/src/events.rs
index 9cda846..948e86a 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -75,8 +75,10 @@ impl fmt::Display for Events {
fn rrule(value: &String, params: &Vec<(String, Vec<String>)>) -> Result<Periodic, EventError> {
let mut periodic = Periodic::new();
- let p: Vec<&str> = value.splitn(2, "=").collect();
- periodic.set_param(p[0], p[1])?;
+ for entry in value.split(";") {
+ let p: Vec<&str> = entry.splitn(2, "=").collect();
+ periodic.set_param(p[0], p[1])?;
+ }
for (param, values) in params {
let mut value = "";
diff --git a/src/periodic.rs b/src/periodic.rs
index 0fa06ef..e46a13b 100644
--- a/src/periodic.rs
+++ b/src/periodic.rs
@@ -8,7 +8,8 @@ use errors::EventError;
pub struct Periodic {
pub event: Event,
pub freq: Freq,
- // TODO: until, count, interval, ...
+ pub interval: i64,
+ // TODO: until, count, ...
}
#[derive(Debug)]
@@ -27,12 +28,14 @@ impl Periodic {
Self {
event: Event::new(),
freq: Freq::Secondly,
+ interval: 1,
}
}
pub fn set_param(&mut self, param: &str, value: &str) -> Result<(), EventError> {
match param {
"FREQ" => self.freq = value.parse()?,
+ "INTERVAL" => self.interval = value.parse()?,
_ => (),
}
Ok(())
@@ -41,7 +44,11 @@ impl Periodic {
impl fmt::Display for Periodic {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}: {}", self.freq, self.event)?;
+ write!(f, "{:?}", self.freq)?;
+ if self.interval != 1 {
+ write!(f, "({})", self.interval)?;
+ }
+ write!(f, ": {}", self.event)?;
Ok(())
}
}