use std::fmt::Display;
use crate::{is_feb29_between_exc_inc, DayCountFraction, DayCounter};
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
pub struct NL365;
impl DayCounter for NL365 {
fn day_count_fraction(
&self,
start: &chrono::NaiveDate,
end: &chrono::NaiveDate,
) -> DayCountFraction<Self> {
let mut numerator = (*end - *start).num_days();
if is_feb29_between_exc_inc(*start, *end) {
numerator -= 1;
}
DayCountFraction::new(numerator as f64 / 365.0)
}
}
impl Display for NL365 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "NL/365")
}
}