mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 14:08:23 +00:00
small fixes
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1771,7 +1771,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ical"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/lennart-k/ical-rs?branch=dev#169df28e8065f26d61f33367279e2516dc882c89"
|
||||
source = "git+https://github.com/lennart-k/ical-rs?branch=dev#5525818e2fca0fc99cbe0b0c0fb260d0d790f43f"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
|
||||
@@ -139,7 +139,10 @@ END:VCALENDAR";
|
||||
prop_filter: vec![],
|
||||
comp_filter: vec![],
|
||||
};
|
||||
assert!(!object.matches(&comp_filter), "filter: wants no VCALENDAR");
|
||||
assert!(
|
||||
!object.get_inner().matches(&comp_filter),
|
||||
"filter: wants no VCALENDAR"
|
||||
);
|
||||
|
||||
let comp_filter = CompFilterElement {
|
||||
is_not_defined: None,
|
||||
@@ -154,7 +157,10 @@ END:VCALENDAR";
|
||||
comp_filter: vec![],
|
||||
}],
|
||||
};
|
||||
assert!(!object.matches(&comp_filter), "filter matches VTODO");
|
||||
assert!(
|
||||
!object.get_inner().matches(&comp_filter),
|
||||
"filter matches VTODO"
|
||||
);
|
||||
|
||||
let comp_filter = CompFilterElement {
|
||||
is_not_defined: None,
|
||||
@@ -169,7 +175,10 @@ END:VCALENDAR";
|
||||
comp_filter: vec![],
|
||||
}],
|
||||
};
|
||||
assert!(object.matches(&comp_filter), "filter matches VEVENT");
|
||||
assert!(
|
||||
object.get_inner().matches(&comp_filter),
|
||||
"filter matches VEVENT"
|
||||
);
|
||||
|
||||
let comp_filter = CompFilterElement {
|
||||
is_not_defined: None,
|
||||
@@ -216,7 +225,7 @@ END:VCALENDAR";
|
||||
}],
|
||||
};
|
||||
assert!(
|
||||
object.matches(&comp_filter),
|
||||
object.get_inner().matches(&comp_filter),
|
||||
"Some prop filters on VCALENDAR and VEVENT"
|
||||
);
|
||||
}
|
||||
@@ -245,7 +254,7 @@ END:VCALENDAR";
|
||||
}],
|
||||
};
|
||||
assert!(
|
||||
object.matches(&comp_filter),
|
||||
object.get_inner().matches(&comp_filter),
|
||||
"event should lie in time range"
|
||||
);
|
||||
|
||||
@@ -270,7 +279,7 @@ END:VCALENDAR";
|
||||
}],
|
||||
};
|
||||
assert!(
|
||||
!object.matches(&comp_filter),
|
||||
!object.get_inner().matches(&comp_filter),
|
||||
"event should not lie in time range"
|
||||
);
|
||||
}
|
||||
@@ -304,7 +313,7 @@ END:VCALENDAR";
|
||||
}],
|
||||
};
|
||||
assert!(
|
||||
object.matches(&comp_filter),
|
||||
object.get_inner().matches(&comp_filter),
|
||||
"Timezone should be Europe/Berlin"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,5 +79,5 @@ const FILTER_2: &str = r#"
|
||||
fn yeet(#[case] ics: &str, #[case] filter: &str, #[case] matches: bool) {
|
||||
let obj = CalendarObject::from_ics(ics.to_owned(), None).unwrap();
|
||||
let filter = FilterElement::parse_str(filter).unwrap();
|
||||
assert_eq!(matches, filter.matches(&obj));
|
||||
assert_eq!(matches, filter.matches(obj.get_inner()));
|
||||
}
|
||||
|
||||
@@ -54,10 +54,11 @@ impl Resource for CalendarObjectResource {
|
||||
}
|
||||
CalendarObjectPropName::CalendarData(CalendarData { expand, .. }) => {
|
||||
CalendarObjectProp::CalendarData(if let Some(expand) = expand.as_ref() {
|
||||
self.object.expand_recurrence(
|
||||
Some(expand.start.to_utc()),
|
||||
Some(expand.end.to_utc()),
|
||||
)?
|
||||
todo!()
|
||||
// self.object.get_inner().expand_recurrence(
|
||||
// Some(expand.start.to_utc()),
|
||||
// Some(expand.end.to_utc()),
|
||||
// )
|
||||
} else {
|
||||
self.object.get_ics().to_owned()
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ use ical::parser::{
|
||||
Component,
|
||||
vcard::{self, component::VcardContact},
|
||||
};
|
||||
use ical::types::CalDateTime;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{collections::HashMap, io::BufReader};
|
||||
|
||||
@@ -62,20 +61,6 @@ impl AddressObject {
|
||||
&self.vcf
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_anniversary(&self) -> Option<(CalDateTime, bool)> {
|
||||
// let prop = self.vcard.get_property("ANNIVERSARY")?.value.as_deref()?;
|
||||
// CalDateTime::parse_vcard(prop).ok()
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_birthday(&self) -> Option<(CalDateTime, bool)> {
|
||||
todo!()
|
||||
// let prop = self.vcard.get_property("BDAY")?.value.as_deref()?;
|
||||
// CalDateTime::parse_vcard(prop).ok()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_full_name(&self) -> Option<&str> {
|
||||
let prop = self.vcard.get_property("FN")?;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use crate::Error;
|
||||
use chrono::DateTime;
|
||||
use chrono::Utc;
|
||||
use derive_more::Display;
|
||||
use ical::component::CalendarInnerData;
|
||||
use ical::component::IcalCalendarObject;
|
||||
@@ -115,22 +113,8 @@ impl CalendarObject {
|
||||
&self.ics
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_component_name(&self) -> &str {
|
||||
self.get_object_type().as_str()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_object_type(&self) -> CalendarObjectType {
|
||||
(&self.inner).into()
|
||||
}
|
||||
|
||||
pub fn expand_recurrence(
|
||||
&self,
|
||||
start: Option<DateTime<Utc>>,
|
||||
end: Option<DateTime<Utc>>,
|
||||
) -> Result<String, Error> {
|
||||
// Ok(self.inner.expand_recurrence(start, end)?)
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use derive_more::derive::Deref;
|
||||
use rustical_xml::{ValueDeserialize, ValueSerialize};
|
||||
|
||||
const LOCAL_DATE_TIME: &str = "%Y%m%dT%H%M%S";
|
||||
const UTC_DATE_TIME: &str = "%Y%m%dT%H%M%SZ";
|
||||
pub const LOCAL_DATE: &str = "%Y%m%d";
|
||||
|
||||
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
||||
pub enum CalDateTimeError {
|
||||
|
||||
@@ -26,5 +26,5 @@ END:VCALENDAR
|
||||
#[test]
|
||||
fn parse_calendar_object() {
|
||||
let object = CalendarObject::from_ics(MULTI_VEVENT.to_string(), None).unwrap();
|
||||
object.expand_recurrence(None, None).unwrap();
|
||||
object.get_inner().expand_recurrence(None, None);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user