calends
calends is a library for durations, intervals and other calendar related operations. It is designed to work with chrono.
Durations of time
A [RelativeDuration] is a unit of time that has some ability to be applied to a date to produce another date.
use RelativeDuration;
use NaiveDate;
// This will allow you to add one month and then go back two days from the added month
let rd = months.with_days;
// It also compatible with NaiveDate
assert_eq!;
Recurrence & Rules
[Recurrence] allows you to specify a ruleset for how events (dates) repeat in time.
use ;
use NaiveDate;
let date = from_ymd;
let end = from_ymd;
let mut recur = with_start.until;
assert_eq!;
assert_eq!;
assert_eq!;
Intervals
An interval is a span of time that can be bound or unbound. This means that you can iterate until the beginning/end of the time. However in practice this will be limited by chronos types.
This will likely be used to do things like iterate by week, month, quarter, or year.
use ;
use ;
use NaiveDate;
let start = from_ymd;
let duration = months;
let mut interval = from_start;
assert_eq!;
assert_eq!;
// Intervals are also iterable because they always have a duration!
// they are inclusive so they return the current time span first
let next = interval.next.unwrap;
assert_eq!;
assert_eq!;
let next = interval.next.unwrap;
assert_eq!;
assert_eq!;
In combination with RelativeDuration you can do things such as iterate the second to last day of the month.
use ;
use NaiveDate;
let duration = months.with_days;
let start = from_ymd;
let mut interval = from_start;
License: MIT