diff options
Diffstat (limited to 'src/event.rs')
-rw-r--r-- | src/event.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs index b54c422..d086295 100644 --- a/src/event.rs +++ b/src/event.rs @@ -82,3 +82,17 @@ impl FromStr for Status { } } } + + +pub fn get<'a>(events: &'a Vec<Event>, first: &Date, last: &Date) -> &'a [Event] { + match events.iter().position(|ref e| e.start >= *first) { + None => &[], + Some(i) => { + let j = events + .iter() + .position(|ref e| e.end_date() > *last) + .unwrap_or(events.len()); + &events[i..j] + } + } +} |