bdays
Provides functions to perform business days calculation between dates, given a Holiday Calendar.
A Business Day is defined as a weekday that is not a holiday.
To check if a date is a holiday, you must provide an implementation of the HolidayCalendar trait.
This crate is a port of BusinessDays.jl to the Rust programming language.
Provided Holiday Calendars
This crate provides a set of built-in holiday calendars in the bdays::calendars submodule.
-
bdays::calendars::WeekendsOnly: accounts only weekends -
bdays::calendars::brazil::BRSettlement: Brazilian banking holidays -
bdays::calendars::brazil::BrazilExchange: BMF&BOVESPA Exchange holidays (http://www.bmfbovespa.com.br) -
bdays::calendars::us::USSettlement: United States federal holidays
Usage
extern crate bdays;
extern crate chrono;
use NaiveDate;
use HolidayCalendar;
// creates a holiday calendar instance
let cal = WeekendsOnly;
let d0 = from_ymd;
let d1 = from_ymd;
let d2 = from_ymd;
// checks if a date is a holiday
assert_eq!;
// checks if a date is a business day
assert_eq!;
assert_eq!;
// adjusts to the last/next business day
assert_eq!;
assert_eq!;
// advances a number of business days
assert_eq!;
assert_eq!;
// returns the number of business days between dates
assert_eq!;
assert_eq!;
HolidayCalendarCache
As a motivation, this example might take some time to finish.
extern crate bdays;
extern crate chrono;
use NaiveDate;
use HolidayCalendar;
let cal = BRSettlement;
let d0 = from_ymd;
let d1 = from_ymd;
for _i in 0..30
You can use HolidayCalendarCache to perform fast business days calculation
for a given range of dates.
extern crate bdays;
extern crate chrono;
use NaiveDate;
use HolidayCalendar;
let cal = new;
let d0 = from_ymd;
let d1 = from_ymd;
for _i in 0..30