From 26ddc4889560ea1e63e7fec674fbd87bb394acfb Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Sun, 29 Apr 2018 20:10:43 +0200 Subject: Add Events type --- src/event.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 904e550..92b91ed 100644 --- a/src/event.rs +++ b/src/event.rs @@ -3,10 +3,10 @@ use std::fmt; use std::str::FromStr; use chrono; -use chrono::prelude::{DateTime, TimeZone}; +use chrono::TimeZone; use chrono_tz::{Tz, UTC}; -use ics::IcsError; +use errors::EventError; #[derive(Debug)] @@ -21,7 +21,7 @@ pub struct Event { #[derive(Debug)] pub enum Date { - Time(DateTime), + Time(chrono::DateTime), AllDay(chrono::Date), } @@ -77,7 +77,7 @@ impl Date { } } - pub fn parse(date: String, time_zone: String) -> Result { + pub fn parse(date: &String, time_zone: &String) -> Result { let tz: Tz = time_zone.parse().unwrap_or(UTC); let date = match date.find("T") { Some(_) => { @@ -102,19 +102,19 @@ impl Date { } impl FromStr for Status { - type Err = IcsError; + type Err = EventError; fn from_str(s: &str) -> Result { match s { "CONFIRMED" => Ok(Status::Confirmed), "TENTATIVE" => Ok(Status::Tentative), "CANCELED" => Ok(Status::Canceled), - _ => Err(IcsError::StatusError), + _ => Err(EventError::StatusError), } } } -fn cmp_date_time(date: &chrono::Date, time: &DateTime) -> Ordering { +fn cmp_date_time(date: &chrono::Date, time: &chrono::DateTime) -> Ordering { let d2 = time.date(); if date.eq(&d2) { return Ordering::Less; -- cgit v1.2.3