Skip to content

Commit

Permalink
chore: #142 - Add calendar boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
avhz committed Nov 12, 2023
1 parent 0350a53 commit 7c66f4e
Show file tree
Hide file tree
Showing 31 changed files with 1,141 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/time/calendars/czech_republic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/denmark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/finland.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/france.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/germany.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/hong_kong.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/hungary.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/iceland.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/india.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
38 changes: 38 additions & 0 deletions src/time/calendars/indonesia.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RustQuant: A Rust library for quantitative finance tools.
// Copyright (C) 2023 https://github.com/avhz
// Dual licensed under Apache 2.0 and MIT.
// See:
// - LICENSE-APACHE.md
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use crate::time::Calendar;
use time::{Month, OffsetDateTime, Weekday};

/// Czech Republic calendar.
pub struct CzechRepublic;

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

fn is_business_day(&self, date: OffsetDateTime) -> bool {
let (w, d, m, y, dd) = self.unpack_date(date);
let em = Self::easter_monday(y as usize, false);

if Self::is_weekend(date) {
return false;
}

true
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// UNIT TESTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#[cfg(test)]
mod tests {}
Loading

0 comments on commit 7c66f4e

Please sign in to comment.