Implementation:Avhz RustQuant India Calendar
| Knowledge Sources | |
|---|---|
| Domains | Calendar, Time_Value_of_Money |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete tool for determining Indian national holidays for business day calculations provided by the RustQuant library.
Description
The India Calendar module implements the is_holiday_impl_india function, which is the country-specific holiday detection backend for the Indian market within the Calendar system. When a Calendar is configured with Market::India, calls to is_holiday delegate to this function.
The function uses unpack_date to extract the year, month, day, weekday, ordinal day of the year, and Easter Monday offset. It then checks the date against the following Indian public holidays:
- Republic Day -- January 26 (fixed)
- Mahashivratri -- variable, lookup table from 2000 to 2029
- Holi -- variable (March), lookup table from 2000 to 2029
- Good Friday -- computed as Easter Monday minus 3 days
- Eid-ul-Fitar -- variable, lookup table from 2000 to 2029
- Rama Navami -- variable (March/April), lookup table from 2000 to 2029
- Mahavir Jayanti -- variable (March/April), lookup table from 2005 to 2025
- Maharashtra Day -- May 1 (fixed)
- Bakri Id (Eid-ul-Adha) -- variable, lookup table from 2000 to 2029
- Muharram -- variable, lookup table from 2007 to 2029
- Independence Day -- August 15 (fixed)
- Gandhi Jayanti -- October 2 (fixed)
- Dussehra -- variable (September/October), lookup table from 2000 to 2029
- Diwali -- variable (October/November), lookup table from 2000 to 2029
- Gurunanak Jayanti -- variable (November), lookup table from 2005 to 2025
- Christmas -- December 25 (fixed)
Each moveable holiday is implemented as a separate helper function (e.g., is_mahashivratri, is_holi, is_diwali) that uses Rust matches! macro pattern matching against a hardcoded table of (year, day, month) tuples. The coverage spans years 2000 through 2029 for most holidays.
The module includes unit tests verifying weekend detection, public holiday detection for 2024, and regular business day identification.
Usage
Use this when you need to determine whether a given date is a business day on the Indian market calendar. This is typically used indirectly through the Calendar struct configured with Market::India.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_time/src/countries/india.rs
- Lines: 1-468
Signature
pub(crate) fn is_holiday_impl_india(date: Date) -> bool;
fn is_mahashivratri(year: i32, day: u8, month: Month) -> bool;
fn is_holi(year: i32, day: u8, month: Month) -> bool;
fn is_eid_ul_fitar(year: i32, day: u8, month: Month) -> bool;
fn is_rama_navami(year: i32, day: u8, month: Month) -> bool;
fn is_mahavir_jayanti(year: i32, day: u8, month: Month) -> bool;
fn is_bakri_id(year: i32, day: u8, month: Month) -> bool;
fn is_muharram(year: i32, day: u8, month: Month) -> bool;
fn is_dussehra(year: i32, day: u8, month: Month) -> bool;
fn is_diwali(year: i32, day: u8, month: Month) -> bool;
fn is_gurunanak_jayanti(year: i32, day: u8, month: Month) -> bool;
Import
use RustQuant::time::calendar::{Calendar, Market};
// Used indirectly via:
let calendar = Calendar::new(Market::India);
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| date | Date | Yes | The date to check for an Indian public holiday |
Outputs
| Name | Type | Description |
|---|---|---|
| result | bool | true if the date is a recognized Indian public holiday, false otherwise
|
Usage Examples
use time::macros::date;
use RustQuant::time::calendar::{Calendar, Market};
let calendar = Calendar::new(Market::India);
// Republic Day (January 26)
let republic_day = date!(2024-01-26);
assert!(!calendar.is_business_day(republic_day));
// Diwali 2024 (October 31)
let diwali = date!(2024-10-31);
assert!(!calendar.is_business_day(diwali));
// Independence Day (August 15)
let independence_day = date!(2024-08-15);
assert!(!calendar.is_business_day(independence_day));
// A regular business day
let regular_day = date!(2024-03-22);
assert!(calendar.is_business_day(regular_day));
// Weekends are not business days
let saturday = date!(2024-03-09);
assert!(!calendar.is_business_day(saturday));