summaryrefslogtreecommitdiff
path: root/src/rrule.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rrule.rs')
-rw-r--r--src/rrule.rs56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/rrule.rs b/src/rrule.rs
index 5ed5748..92b2ba5 100644
--- a/src/rrule.rs
+++ b/src/rrule.rs
@@ -1 +1,55 @@
-pub struct RRule {}
+use crate::iter::*;
+use crate::options::*;
+use chrono::prelude::*;
+use chrono_tz::{Tz, UTC};
+
+pub struct RRule {
+ cache: bool,
+ pub options: ParsedOptions,
+}
+
+impl RRule {
+ pub fn new(options: ParsedOptions) -> Self {
+ Self {
+ options,
+ cache: true,
+ }
+ }
+
+ pub fn disable_cache(&mut self) {
+ self.cache = false;
+ }
+
+ pub fn all(&mut self) -> Vec<DateTime<Tz>> {
+ let iter_args = IterArgs {
+ inc: true,
+ before: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0),
+ after: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0),
+ dt: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0),
+ _value: Some(vec![]),
+ };
+ let mut iter_res = IterResult::new(QueryMethodTypes::ALL, iter_args);
+
+ let res = iter(&mut iter_res, &mut self.options);
+ res
+ }
+
+ pub fn between(
+ &mut self,
+ after: &DateTime<Tz>,
+ before: &DateTime<Tz>,
+ inc: bool,
+ ) -> Vec<DateTime<Tz>> {
+ let iter_args = IterArgs {
+ inc,
+ before: before.clone(),
+ after: after.clone(),
+ dt: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0),
+ _value: Some(vec![]),
+ };
+ let mut iter_res = IterResult::new(QueryMethodTypes::ALL, iter_args);
+
+ let res = iter(&mut iter_res, &mut self.options);
+ res
+ }
+}