diff options
author | Till Höppner | 2015-06-11 20:57:39 +0200 |
---|---|---|
committer | Till Höppner | 2015-06-11 20:57:39 +0200 |
commit | bc755a4dedc520b672bc7168ff6ef9d088072d99 (patch) | |
tree | 52bed0ed50693bb9f5bbdc52fa81d7e1edfb855c /src/freq.rs | |
parent | 86fe3230866082d6207eb5253f2e89623b941f63 (diff) | |
parent | ccc9f5e8eaa84579da610ea0d90d18596078bac7 (diff) | |
download | ilc-bc755a4dedc520b672bc7168ff6ef9d088072d99.tar.gz ilc-bc755a4dedc520b672bc7168ff6ef9d088072d99.tar.xz ilc-bc755a4dedc520b672bc7168ff6ef9d088072d99.zip |
Merge pull request #1 from tilpner/cows
Update Event API with Option and Cow
Diffstat (limited to 'src/freq.rs')
-rw-r--r-- | src/freq.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/freq.rs b/src/freq.rs index 0ca4875..25810e7 100644 --- a/src/freq.rs +++ b/src/freq.rs @@ -13,11 +13,16 @@ // limitations under the License. extern crate ilc; +extern crate chrono; use std::io; use std::collections::hash_map::*; -use ilc::log::Event::*; +use chrono::offset::fixed::FixedOffset; +use chrono::naive::date::NaiveDate; + +use ilc::event::{ Event, Type }; +use ilc::context::Context; use ilc::format::{ self, Decode }; struct Person { @@ -41,16 +46,20 @@ fn main() { let stdin = io::stdin(); let mut stats: HashMap<String, Person> = HashMap::new(); + let context = Context { + timezone: FixedOffset::west(0), + override_date: NaiveDate::from_ymd(2015, 6, 10) + }; let mut parser = format::weechat3::Weechat3; - for e in parser.decode(stdin.lock()) { + for e in parser.decode(&context, stdin.lock()) { let m = match e { Ok(m) => m, Err(err) => panic!(err) }; match m { - Msg { ref from, ref content, .. } => { + Event { ty: Type::Msg { ref from, ref content, .. }, .. } => { let nick = strip_nick(from); if stats.contains_key(nick) { let p: &mut Person = stats.get_mut(nick).unwrap(); |