mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
prop-filter: Add time-range checking
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use ical::{
|
use ical::{
|
||||||
generator::{IcalCalendar, IcalEvent},
|
generator::{IcalCalendar, IcalEvent},
|
||||||
parser::{
|
parser::{
|
||||||
@@ -6,7 +8,7 @@ use ical::{
|
|||||||
},
|
},
|
||||||
property::Property,
|
property::Property,
|
||||||
};
|
};
|
||||||
use rustical_ical::{CalendarObject, CalendarObjectComponent};
|
use rustical_ical::{CalDateTime, CalendarObject, CalendarObjectComponent, UtcDateTime};
|
||||||
use rustical_xml::XmlDeserialize;
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
use crate::calendar::methods::report::calendar_query::{
|
use crate::calendar::methods::report::calendar_query::{
|
||||||
@@ -43,8 +45,22 @@ impl PropFilterElement {
|
|||||||
(false, Some(property)) => property
|
(false, Some(property)) => property
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(_time_range) = &self.time_range {
|
if let Some(TimeRangeElement { start, end }) = &self.time_range {
|
||||||
// TODO: implement
|
// TODO: Respect timezones
|
||||||
|
let Ok(timestamp) = CalDateTime::parse_prop(property, &HashMap::default()) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let timestamp = timestamp.utc();
|
||||||
|
if let Some(UtcDateTime(start)) = start
|
||||||
|
&& start > ×tamp
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if let Some(UtcDateTime(end)) = end
|
||||||
|
&& end < ×tamp
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user