summaryrefslogtreecommitdiff
path: root/src/rrule.rs
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-10-19 17:24:58 +0200
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-10-19 17:24:58 +0200
commitf534bf215960933fb54be42a534aeb4ebdd59606 (patch)
tree1f7abd8b5c154ecf0c0c485ae2d5dd868f9b9629 /src/rrule.rs
parentaa5cf33bb89213d744089015c95b0da6bf0f59b3 (diff)
downloadrust_rrule-f534bf215960933fb54be42a534aeb4ebdd59606.zip
maybe progress
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
+ }
+}