aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs1
-rw-r--r--src/main.rs31
2 files changed, 22 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 85ba6c0..e754a11 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,3 +11,4 @@ mod errors;
pub use calendar::Calendar;
pub use date::Date;
pub use chrono::Duration;
+pub use event::Event;
diff --git a/src/main.rs b/src/main.rs
index 6d9544b..ce2284d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,19 +3,30 @@ extern crate almanac;
use std::env;
use std::io::BufReader;
use std::fs::File;
-use almanac::Duration;
-use almanac::Date;
+
use almanac::Calendar;
+use almanac::Date;
+use almanac::Duration;
+use almanac::Event;
fn main() {
- let args: Vec<_> = env::args().collect();
- let file = File::open(&args[1]).unwrap();
- let buf = BufReader::new(file);
- let calendar = Calendar::parse(buf).unwrap();
+ let first = Date::now();
+ let last = first + Duration::days(7);
- let now = Date::now();
- let events = calendar.get(&now, &(now + Duration::days(1)));
- for e in events {
- println!("{}", e);
+ let mut events: Vec<_> = env::args()
+ .skip(1)
+ .map(|arg| ics_calendar(&arg, &first, &last))
+ .flatten()
+ .collect();
+ events.sort();
+ for event in events {
+ println!("{}", event);
}
}
+
+fn ics_calendar(file_path: &str, first: &Date, last: &Date) -> Vec<Event> {
+ let file = File::open(file_path).unwrap();
+ let buf = BufReader::new(file);
+ let calendar = Calendar::parse(buf).unwrap();
+ calendar.get(first, last)
+}