Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/business.rs
6940 views
1
use std::fmt;
2
3
use polars_ops::prelude::Roll;
4
#[cfg(feature = "serde")]
5
use serde::{Deserialize, Serialize};
6
7
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
9
#[derive(Clone, PartialEq, Debug, Eq, Hash)]
10
pub enum BusinessFunction {
11
BusinessDayCount {
12
week_mask: [bool; 7],
13
holidays: Vec<i32>,
14
},
15
AddBusinessDay {
16
week_mask: [bool; 7],
17
holidays: Vec<i32>,
18
roll: Roll,
19
},
20
IsBusinessDay {
21
week_mask: [bool; 7],
22
holidays: Vec<i32>,
23
},
24
}
25
26
impl fmt::Display for BusinessFunction {
27
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
28
use BusinessFunction::*;
29
let s = match self {
30
BusinessDayCount { .. } => "business_day_count",
31
AddBusinessDay { .. } => "add_business_days",
32
IsBusinessDay { .. } => "is_business_day",
33
};
34
write!(f, "{s}")
35
}
36
}
37
38