summaryrefslogtreecommitdiffstats
path: root/src/khline.rs
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-03-09 17:15:14 +0100
committerNora <nora.widdecke@tu-bs.de>2019-03-09 17:15:14 +0100
commit5607b7c2718bdc29b1eaced8821d823f31b4c1be (patch)
tree990467b3cbaf0a962ea8b40318d2069dbe66e8aa /src/khline.rs
parent9490bf527cbfd258d1c6705569d7e3dc395c5d33 (diff)
working khevent
Diffstat (limited to 'src/khline.rs')
-rw-r--r--src/khline.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/khline.rs b/src/khline.rs
index ffb79a3..03a6407 100644
--- a/src/khline.rs
+++ b/src/khline.rs
@@ -31,19 +31,24 @@ impl KhLine {
Ok(calendar)
}
- pub fn to_event(&self) -> io::Result<IcalVEvent> {
+ pub fn to_event(&self) -> io::Result<KhEvent> {
let calendar = self.to_cal()?;
let mut event = calendar.get_first_event();
- if let Some(ref time) = self.time {
- event = event.with_internal_timestamp(time);
- }
- Ok(event)
+ Ok(KhEvent::from_event_with_timestamp(event, self.time.clone()))
+ //if let Some(ref time) = self.time {
+ //event = event.with_internal_timestamp(time);
+ //}
+ //Ok(event)
}
pub fn with_index(self, index: usize) -> Self {
Self { path: self.path, time: self.time, index: Some(index) }
}
+ pub fn matches_khevent(&self, event: &KhEvent) -> bool {
+ self == &KhLine::from(event)
+ }
+
pub fn matches(&self, event: &IcalVEvent) -> bool {
self == &KhLine::from(event)
}
@@ -66,6 +71,15 @@ impl KhLine {
impl From<&IcalVEvent> for KhLine {
fn from(event: &IcalVEvent) -> Self {
let path = event.get_parent().unwrap().get_path().unwrap().to_path_buf();
+ let time = event.get_dtstart();
+
+ KhLine{ path, time, index: None }
+ }
+}
+
+impl From<&KhEvent> for KhLine {
+ fn from(event: &KhEvent) -> Self {
+ let path = event.event.get_parent().unwrap().get_path().unwrap().to_path_buf();
let time = event.get_start();
KhLine{ path, time, index: None }
@@ -127,7 +141,7 @@ pub fn lines_to_khlines_indexed(lines: impl Iterator<Item = String>) -> impl Ite
.flatten()
}
-pub fn khlines_to_events(lines: impl Iterator<Item = KhLine>) -> impl Iterator<Item = IcalVEvent> {
+pub fn khlines_to_events(lines: impl Iterator<Item = KhLine>) -> impl Iterator<Item = KhEvent> {
lines.map(|line| line.to_event()).flatten()
}