aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan2021-09-29 20:57:59 +0200
committerRuben Pollan2021-09-29 20:57:59 +0200
commitfdd31db66de648526748188b55c83928fab8969f (patch)
treee2c55806465c0aaaee5494ab17417d91cb74c3c6 /src
parent4116776e1d78568febf98b183738ae82263f01eb (diff)
Acknoledge the BYSETOPS frequency param
Diffstat (limited to '')
-rw-r--r--src/periodic.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/periodic.rs b/src/periodic.rs
index c0d0ad3..2891bed 100644
--- a/src/periodic.rs
+++ b/src/periodic.rs
@@ -19,6 +19,7 @@ pub struct Periodic {
pub count: Option<i64>,
pub until: Option<Date>,
pub byday: Option<Byday>,
+ pub bysetpos: i32,
pub wkst: Weekday,
}
@@ -42,6 +43,7 @@ impl Periodic {
count: None,
until: None,
byday: None,
+ bysetpos: 0,
wkst: Weekday::Mon,
}
}
@@ -53,6 +55,7 @@ impl Periodic {
"COUNT" => self.count = Some(value.parse()?),
"UNTIL" => self.until = Some(Date::parse(&value, "")?),
"BYDAY" => self.byday = Some(parse_byday(value)?),
+ "BYSETPOS" => self.bysetpos = value.parse()?,
"WKST" => self.wkst = parse_weekday(value)?,
_ => (),
}
@@ -134,6 +137,7 @@ impl<'a> Iter<'a> {
Some(byday) => {
let mut next = date;
if p.interval > 1 {
+ next = next.with_day(1).unwrap();
for _ in 1..p.interval {
next = next.add(Duration::days(next.days_in_month().into()));
}
@@ -144,7 +148,9 @@ impl<'a> Iter<'a> {
match byday.get(&next.weekday()) {
Some(occurrences) =>
- if occurrences.contains(&0) || occurrences.contains(&week) ||occurrences.contains(&neg_week) {
+ if p.bysetpos == week || p.bysetpos == neg_week
+ || occurrences.contains(&0)
+ || occurrences.contains(&week) || occurrences.contains(&neg_week) {
break;
}
None => {}