How to check if two RRules overlapping
Closed this issue · 1 comments
suren4Kites commented
If I have one RRule for weekly and another for monthly. Is there any way that I can check whether overlapping is possible?
zensh commented
package main
import (
"fmt"
"github.com/teambition/rrule-go"
)
func main() {
r1, _ := rrule.StrToRRule("FREQ=DAILY;DTSTART=19970902T015959Z;COUNT=1000")
r2, _ := rrule.StrToRRule("FREQ=DAILY;DTSTART=19980902T015959Z;COUNT=100")
all := r1.All()
cur := 0
iter := r2.Iterator()
for {
val, ok := iter()
if !ok {
break
}
for {
if cur >= len(all) {
break
}
if val.After(all[cur]) {
cur++
continue
} else if val.Equal(all[cur]) {
fmt.Println("overlapping ", val)
cur++
}
break
}
}
}