diff options
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs index 31f884b..dc2d186 100644 --- a/src/options.rs +++ b/src/options.rs @@ -113,88 +113,126 @@ impl Options { } } + /// The FREQ rule part identifies the type of recurrence rule. pub fn freq(mut self, freq: Frequenzy) -> Self { self.freq = Some(freq); self } + /// The interval between each freq iteration. pub fn interval(mut self, interval: usize) -> Self { self.interval = Some(interval); self } + /// If given, this determines how many occurrences will be generated. pub fn count(mut self, count: u32) -> Self { self.count = Some(count); self } + /// If given, this must be a datetime instance specifying the + /// upper-bound limit of the recurrence. pub fn until(mut self, until: DateTime<Utc>) -> Self { self.until = Some(until.with_timezone(&UTC)); self } + /// The recurrence start. Recurrences generated by the rrule will + /// be in the same time zone as the start date. pub fn dtstart(mut self, dtstart: DTime) -> Self { self.dtstart = Some(dtstart); self.tzid = Some(dtstart.timezone()); self } + /// The week start day. This will affect recurrences based on weekly periods. The default week start is Weekday::Mon. pub fn wkst(mut self, wkst: Weekday) -> Self { self.wkst = Some(get_weekday_val(&wkst)); self } + /// If given, it must be either an integer, or a sequence of integers, positive or negative. + /// Each given integer will specify an occurrence number, corresponding to the nth occurrence + /// of the rule inside the frequency period. For example, a bysetpos of -1 if combined with + /// a MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will result in the last + /// work day of every month. pub fn bysetpos(mut self, bysetpos: Vec<isize>) -> Self { self.bysetpos = Some(bysetpos); self } + /// If given, it must be either an integer, or a sequence of integers, meaning + /// the months to apply the recurrence to. pub fn bymonth(mut self, bymonth: Vec<usize>) -> Self { self.bymonth = Some(bymonth); self } + /// If given, it must be either an integer, or a sequence of integers, meaning + /// the month days to apply the recurrence to. pub fn bymonthday(mut self, bymonthday: Vec<isize>) -> Self { self.bymonthday = Some(bymonthday); self } + /// If given, it must be either an integer, or a sequence of integers, meaning + /// the year days to apply the recurrence to. pub fn byyearday(mut self, byyearday: Vec<isize>) -> Self { self.byyearday = Some(byyearday); self } + /// If given, it must be either an integer, or a sequence of integers, meaning + /// the week numbers to apply the recurrence to. Week numbers have the meaning + /// described in ISO8601, that is, the first week of the year is that containing + /// at least four days of the new year. pub fn byweekno(mut self, byweekno: Vec<isize>) -> Self { self.byweekno = Some(byweekno); self } + /// If given, it must be either an integer (0 == MO), a sequence of integers, one + /// of the weekday constants (MO, TU, etc), or a sequence of these constants. + /// When given, these variables will define the weekdays where the recurrence + /// will be applied. pub fn byweekday(mut self, byweekday: Vec<Weekday>) -> Self { let byweekday = byweekday.iter().map(|w| get_weekday_val(w)).collect(); self.byweekday = Some(byweekday); self } + /// If given, it must be either an integer, or a sequence of integers, + /// meaning the hours to apply the recurrence to. pub fn byhour(mut self, byhour: Vec<usize>) -> Self { self.byhour = Some(byhour); self } + /// If given, it must be either an integer, or a sequence of integers, + /// meaning the minutes to apply the recurrence to. pub fn byminute(mut self, byminute: Vec<usize>) -> Self { self.byminute = Some(byminute); self } + /// If given, it must be either an integer, or a sequence of integers, + /// meaning the seconds to apply the recurrence to. pub fn bysecond(mut self, bysecond: Vec<usize>) -> Self { self.bysecond = Some(bysecond); self } + /// If given, it must be either an integer, or a sequence of integers, positive or negative. + /// Each integer will define an offset from the Easter Sunday. Passing the offset 0 to + /// byeaster will yield the Easter Sunday itself. This is an extension to the RFC specification. pub fn byeaster(mut self, byeaster: isize) -> Self { self.byeaster = Some(byeaster); self } + /// Parses the opptions and build `ParsedOptions` if they are valid. + /// Otherwise an `RRuleParseError` will be returned. pub fn build(self) -> Result<ParsedOptions, RRuleParseError> { parse_options(&self) } |