RRule
A library to manage recurrence rules following the standards from RFC-5547.
How to use it
To define a recurrence rule, start by creating the desired frequency rule definition:
let daily = Daily ;
Then, create a Recurrence with the frequency defined:
...
let recurrence = new;
The
Recurrencestruct is an iterator that will yield all the dates that match the recurrence rules defined.
You can then use the Recurrence as an iterator by looping over it or collecting the results into a Vec
...
for event in recurrence
# or
let events: = recurrence.collect;
The end attribute of a Recurrence is optional, and if not specified, it will yield events until the MAX_DATE.
The
MAX_DATEis defined as9999-12-31T23:59:59Z
The duration attribute of a Recurrence is optional, and if not specified, it will use the default as 1 hour Duration::hours(1).
Supported frequencies
Current supporting recurrence rules:
Secondly Frequencies
Represents the rules for a recurrence that happens every x seconds.
use Frequency;
let every_second = Secondly ;
let every_5_seconds = Secondly ;
Minutely Frequencies
Represents the rules for a recurrence that happens every x minutes.
use Frequency;
let every_minute = Minutely ;
let every_5_minutes = Minutely ;
Hourly Frequencies
Represents the rules for a recurrence that happens every x hours.
use Frequency;
let every_hour = Hourly ;
let every_6_hours = Hourly ;
Daily Frequencies
Represents the rules for a recurrence that happens x times every x days.
use ;
use ;
let daily = Daily ;
let every_3_days = Daily ;
let every_day_at_8am = Daily ;
Weekly Frequencies
Represents the rules for a recurrence that happens x times every x weeks.
let weekly = Weekly ;
let twice_a_week = Weekly ;
Monthly Frequencies
Represents the rules for a recurrence that happens x times every x months.
let monthly = Monthly ;
Monthly by month day
When specifying by_month_day, it will only yield the dates that match the days of the month specified.
let every_15th = Monthly ;
Monthly by nth day
When specifying nth_weekdays, it will only yield the dates that match the nth days of the week specified.
I.g. if you want to have a recurrence every first Monday of the month, you can do:
let every_first_monday = Monthly ;
Yearly Frequencies
Represents the rules for a recurrence that happens x times every x years.
let yearly = Yearly ;
Yearly by month day
When specifying by_month_date, it will only yield the dates that match the days of the month specified.
E.g. if you want to have a recurrence every 15th January of the year, you can do:
let every_15th_january = Yearly ;