A crate for doing business day calculations. It is a Rust implementation of GoCardless' business Ruby gem.
Let's dive right in with an example. For more details, see [Calendar
].
```rust use chrono::NaiveDate;
let xmas = NaiveDate::from_ymd(2020, 12, 25); // Friday
let cal = business::Calendar::with_holidays(&[xmas]);
asserteq!(cal.isbusiness_day(xmas), false);
// The earliest business day asserteq!(cal.rollforward(xmas), NaiveDate::from_ymd(2020, 12, 28));
let xmaseve = NaiveDate::fromymd(2020, 12, 24); asserteq!(cal.isbusinessday(xmaseve), true);
// Skips over weekend and business holidays asserteq!(cal.addbusinessdays(xmaseve, 2), NaiveDate::from_ymd(2020, 12, 29)); ```
Calendar
from YAMLThe YAML has to be in the following format: ```yaml
working_days: - monday - tuesday - wednesday - thursday - friday
holidays:
- 2017-12-25
- 2017-12-26
A calendar can be built as such:
rust
let yml = std::fs::readtostring("examples/basic/cal.yml").unwrap();
let cal: Calendar = serdeyaml::fromstr(&yml).unwrap();
```