recurring
An event series implementation based on
jiff
which provides a flexible
alternative to jiff
's builtin series iterators provided by the
DateTime::series
,
Date::series
and
Time::series
methods.
The essential types in this crate are:
Pattern
: a trait implemented by recurrence patterns to yield aDateTime
before, after or close to a given instant.Event
: an event with a start and optional end date.Series
: producesEvent
s following a recurrencePattern
.
Features
- Interval-based and cron-based recurrence patterns
- Support for optional event duration to produce series events with start and end date.
- Querying the
Series
for events. before, after or close to a user-defined datetime. - Finding series events containing a given datetime.
- Composition of events following different recurrence patterns into a single series.
- Splitting series at a cutoff point.
- Iterating over a sub-range of a series.
Example: Series
with cron pattern
use ;
use cron;
use date;
let start = date.at;
let pattern = cron.hours.minute.seconds;
let series = new;
let events: = series.iter.take.collect;
assert_eq!;
Example: Series
with interval pattern from a jiff
type
use ;
use daily;
use date;
let start = date.at;
let series = start.to_series.unwrap;
let events: = series.iter.take.collect;
assert_eq!;
Example: Series
with event duration and multiple recurrence patterns
use ;
use cron;
use ;
let start = date.at;
let daily_around_lunch = cron.hour.minute.second;
let first_of_month_in_the_morning = cron.day.hour.minute.second;
let pattern = daily_around_lunch.and;
let series = new
.with
.event_duration
.build
.unwrap;
let events: = series.iter.take.collect;
assert_eq!;
Example: Querying a Series
for events before, after or close to a datetime
use ;
use cron;
use ;
let start = date.at;
let end = date.at;
let pattern = cron.hours.minutes.second;
let series = new;
assert_eq!;
assert_eq!;
assert_eq!;
License
The source code of recurring is licensed under either of Apache License, Version 2.0 or MIT license at your option.