1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//!
//! Date functions
//!
pub use crate::generated::date::*;
use crate::Any;
/// Parameter for DATEDIF()
#[derive(Debug)]
pub enum DateDifMethod {
/// Years
Years,
/// Months
Months,
/// Days
Days,
/// Days, ignoring months and years.
DaysIgnoreMonthsYears,
/// Months, ignoring years.
MonthsIgnoreYears,
/// Days, ignoring years.
DaysIgnoreYears,
}
impl Any for DateDifMethod {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
DateDifMethod::Years => "y",
DateDifMethod::Months => "m",
DateDifMethod::Days => "d",
DateDifMethod::DaysIgnoreMonthsYears => "md",
DateDifMethod::MonthsIgnoreYears => "ym",
DateDifMethod::DaysIgnoreYears => "yd",
});
}
}
/// Parameter for DAYS360()
#[derive(Debug)]
pub enum Days360Method {
/// NASD Method
USNasd,
/// European Method
Europe,
}
impl Any for Days360Method {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
Days360Method::USNasd => "FALSE()",
Days360Method::Europe => "TRUE()",
});
}
}
/// Parameter for WEEKDAY()
#[derive(Debug)]
pub enum WeekdayMethod {
/// Monday first, value 0.
Monday0,
/// Monday first, value 1.
Monday1,
/// Tuesday first, value 1.
Tuesday1,
/// Wednesday first, value 1.
Wednesday1,
/// Thursday first, value 1.
Thursday1,
/// Friday first, value 1.
Friday1,
/// Saturday first, value 1.
Saturday1,
/// Sunday first, value 1.
Sunday1,
}
impl Any for WeekdayMethod {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
WeekdayMethod::Monday0 => "3",
WeekdayMethod::Monday1 => "11",
WeekdayMethod::Tuesday1 => "12",
WeekdayMethod::Wednesday1 => "13",
WeekdayMethod::Thursday1 => "14",
WeekdayMethod::Friday1 => "15",
WeekdayMethod::Saturday1 => "16",
WeekdayMethod::Sunday1 => "17",
});
}
}
/// Parameter for WEEKNUM()
#[derive(Debug)]
pub enum WeeknumMethod {
/// First week contains Jan 1, week starts on Monday.
Jan1WeekMonday,
/// First week contains Jan 1, week starts on Tuesday.
Jan1WeekTuesday,
/// First week contains Jan 1, week starts on Wednesday.
Jan1WeekWednesday,
/// First week contains Jan 1, week starts on Thursday.
Jan1WeekThursday,
/// First week contains Jan 1, week starts on Friday.
Jan1WeekFriday,
/// First week contains Jan 1, week starts on Saturday.
Jan1WeekSaturday,
/// First week contains Jan 1, week starts on Sunday.
Jan1WeekSunday,
/// ISO week number.
ISOWeeknum,
}
impl Any for WeeknumMethod {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
WeeknumMethod::Jan1WeekMonday => "11",
WeeknumMethod::Jan1WeekTuesday => "12",
WeeknumMethod::Jan1WeekWednesday => "13",
WeeknumMethod::Jan1WeekThursday => "14",
WeeknumMethod::Jan1WeekFriday => "15",
WeeknumMethod::Jan1WeekSaturday => "16",
WeeknumMethod::Jan1WeekSunday => "17",
WeeknumMethod::ISOWeeknum => "21",
});
}
}
/// Parameter for YEARFRAC()
#[derive(Debug)]
pub enum YearFracMethod {
///
USNasd30_360,
///
ActualActual,
///
Actual360,
///
Actual365,
///
European30_360,
}
impl Any for YearFracMethod {
fn formula(&self, buf: &mut String) {
buf.push_str(match self {
YearFracMethod::USNasd30_360 => "0",
YearFracMethod::ActualActual => "1",
YearFracMethod::Actual360 => "2",
YearFracMethod::Actual365 => "3",
YearFracMethod::European30_360 => "4",
});
}
}