diff options
Diffstat (limited to 'src/rrule.rs')
-rw-r--r-- | src/rrule.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/rrule.rs b/src/rrule.rs index 68f77ad..c2a080e 100644 --- a/src/rrule.rs +++ b/src/rrule.rs @@ -1,8 +1,10 @@ use crate::iter::iter; use crate::options::*; use crate::rrule_iter::*; +use crate::rrulestr::build_rrule; use chrono::prelude::*; use chrono_tz::Tz; +use std::str::FromStr; #[derive(Clone, Debug)] pub struct RRule { @@ -27,7 +29,7 @@ impl RRule { let res = iter(&mut iter_res, &mut self.options); res } - + /// Returns the last recurrence before the given datetime instance. /// The inc keyword defines what happens if dt is an recurrence. /// With inc == true, if dt itself is an recurrence, it will be returned. @@ -40,7 +42,7 @@ impl RRule { }; let mut iter_res = RRuleIterRes::new(QueryMethodTypes::Before, iter_args); - let recurrences = iter(&mut iter_res, &mut self.options); + let recurrences = iter(&mut iter_res, &mut self.options); if recurrences.is_empty() { None } else { @@ -59,7 +61,7 @@ impl RRule { dt: Some(dt), }; let mut iter_res = RRuleIterRes::new(QueryMethodTypes::After, iter_args); - let recurrences = iter(&mut iter_res, &mut self.options); + let recurrences = iter(&mut iter_res, &mut self.options); if recurrences.is_empty() { None } else { @@ -88,3 +90,11 @@ impl RRule { iter(&mut iter_res, &mut self.options) } } + +impl FromStr for RRule { + type Err = RRuleParseError; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + build_rrule(s) + } +} |