quantlib_rs 0.1.0

A ground-up, idiomatic Rust quantitative finance library inspired by QuantLib.
Documentation
//! Weekends-only calendar (Saturdays and Sundays are non-business days).

use crate::time::calendar::Calendar;
use crate::time::date::Date;

/// A calendar where only Saturdays and Sundays are non-business days.
///
/// # Examples
/// ```
/// use quantlib_rs::time::calendar::Calendar;
/// use quantlib_rs::time::calendars::weekends_only::WeekendsOnly;
/// use quantlib_rs::time::date::{Date, Month};
///
/// let cal = WeekendsOnly;
/// let friday = Date::from_ymd(2026, Month::September, 4).unwrap();
/// let saturday = Date::from_ymd(2026, Month::September, 5).unwrap();
///
/// assert!(cal.is_business_day(friday));
/// assert!(!cal.is_business_day(saturday));
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct WeekendsOnly;

impl Calendar for WeekendsOnly {
    fn name(&self) -> &'static str {
        "Weekends Only"
    }

    #[inline]
    fn is_business_day(&self, date: Date) -> bool {
        !date.weekday().is_weekend()
    }
}