Trait bdays::HolidayCalendar

source ·
pub trait HolidayCalendar<T: Datelike + Copy + PartialOrd> {
    // Required method
    fn is_holiday(&self, date: T) -> bool;

    // Provided methods
    fn is_bday(&self, date: T) -> bool { ... }
    fn to_bday(&self, date: T, adjust_next: bool) -> T { ... }
    fn advance_bdays(&self, date: T, bdays_count: i32) -> T { ... }
    fn bdays(&self, d0: T, d1: T) -> i32 { ... }
}
Expand description

Abstraction for a Holiday Calendar.

Required Methods§

source

fn is_holiday(&self, date: T) -> bool

Returns true if date is a holiday.

Provided Methods§

source

fn is_bday(&self, date: T) -> bool

Returns true if date is a Business Day. A Business Day is defined as a weekday that is not a holiday.

source

fn to_bday(&self, date: T, adjust_next: bool) -> T

Adjusts date to the last/next business day if it’s not a business day.

source

fn advance_bdays(&self, date: T, bdays_count: i32) -> T

Advances bdays_count number of business days from date.

source

fn bdays(&self, d0: T, d1: T) -> i32

Returns the number of business days between d0 and d1.

Implementations on Foreign Types§

source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for Vec<GermanState>

This implementation considers a date a holiday if it is a holiday in any State in the Vec. See the implementation for GermanState for details.

source§

fn is_holiday(&self, date: T) -> bool

Implementors§

source§

impl<T: Datelike + Copy + PartialOrd + Display> HolidayCalendar<T> for HolidayCalendarCache<T>

source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for GermanState

This implementation doesn’t return any holidays before 1990.

Before that the current Germany was separated into the “German Democratic Republic” and the “Federal Republic of Germany” which both had somewhat different holidays. Since this class is called “Germany” it doesn’t really make sense to include the days from the two former countries.

Note that Germany doesn’t have rules for holidays that happen on a Sunday. Those holidays are still holiday days but there is no additional day to make up for the “lost” day.

Also note that German holidays are partly declared by each state there are some weired edge cases:

  • Assumption Day / Mariä Himmelfahrt is only a holiday in Bavaria (BY) if your municipality is mostly catholic which in term depends on census data. Since we don’t have this data but most municipalities in Bavaria are mostly catholic, we count that as holiday for whole Bavaria.
  • There is an Augsburg Peace Festival / Augsburger Friedensfest which only exists in the Bavarian town Augsburg. This is excluded for Bavaria.
  • Maundy Thursday / Gründonnerstag (Thursday before easter) is not a holiday but pupils in Baden Württemberg (BW) don’t have to go to school. It is excluded from our list.
  • Corpus Christi / Fronleichnam is a holiday in certain, explicitly defined municipalities in Saxony (SN) and Thuringia (TH). We exclude it from both provinces.
source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for BRSettlement

source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for BrazilExchange

source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for WeekendsOnly

source§

impl<T: Datelike + Copy + PartialOrd> HolidayCalendar<T> for USSettlement