rrule Day of Week after Nth Day of Month

1.5k views Asked by At

What is the best way to write an rrule that is Tuesday after the third Monday each June?

Currently I write the rule like this:

rule_mo = rrule(freq=YEARLY,              
            bymonth=6, 
            byweekday=MO(+3),
            ...)
rule = (x + relativedelta(weekday=TU(+1)) for x in rule_mo)

Is there a way to write this entire rule using just the rrule and not having to use the second pass with the relativedelta?

1

There are 1 answers

1
codepiper On

Reference : http://jkbr.github.io/rrule/

rule = RRule.fromText("every June on 3rd Tuesday")

rule.origOptions    
{
   freq: RRule.YEARLY,
   bymonth: [6],
   byweekday: [RRule.TU.nth(3)]
}

rule.toString()     

FREQ=YEARLY;BYMONTH=6;BYDAY=+3TU

rule.toText()   every June on the 3rd Tuesday