Expand description
Business-day arithmetic and the HolidayCalendar trait.
Business-day arithmetic with pluggable holiday calendars.
A business day is a Monday to Friday that the calendar does not
flag as a holiday. Dates are judged in the DateTime’s own offset,
and the time of day is kept unchanged.
§Examples
use dtt::business::HolidayCalendar;
use dtt::datetime::DateTime;
/// New Year's Day is a holiday, every year.
struct NewYear;
impl HolidayCalendar for NewYear {
fn is_holiday(&self, dt: &DateTime) -> bool {
dt.month() == time::Month::January && dt.day() == 1
}
}
// From Thursday 2026-12-31 the next business day skips New Year's
// Day (a Friday) and the weekend.
let fri = DateTime::parse("2026-12-31T09:00:00Z")?;
let next = fri.next_business_day_in(&NewYear)?;
assert_eq!(next.format_rfc3339()?, "2027-01-04T09:00:00Z");Structs§
- NoHolidays
- A calendar without holidays: only weekends are skipped.
Traits§
- Holiday
Calendar - Decides which weekdays are holidays.