spreadsheet_ods_formula/
date.rs1pub use crate::generated::date::*;
6
7use crate::Any;
8
9#[derive(Debug)]
11pub enum DateDifMethod {
12 Years,
14 Months,
16 Days,
18 DaysIgnoreMonthsYears,
20 MonthsIgnoreYears,
22 DaysIgnoreYears,
24}
25
26impl Any for DateDifMethod {
27 fn formula(&self, buf: &mut String) {
28 buf.push_str(match self {
29 DateDifMethod::Years => "y",
30 DateDifMethod::Months => "m",
31 DateDifMethod::Days => "d",
32 DateDifMethod::DaysIgnoreMonthsYears => "md",
33 DateDifMethod::MonthsIgnoreYears => "ym",
34 DateDifMethod::DaysIgnoreYears => "yd",
35 });
36 }
37}
38
39#[derive(Debug)]
41pub enum Days360Method {
42 USNasd,
44 Europe,
46}
47
48impl Any for Days360Method {
49 fn formula(&self, buf: &mut String) {
50 buf.push_str(match self {
51 Days360Method::USNasd => "FALSE()",
52 Days360Method::Europe => "TRUE()",
53 });
54 }
55}
56
57#[derive(Debug)]
59pub enum WeekdayMethod {
60 Monday0,
62 Monday1,
64 Tuesday1,
66 Wednesday1,
68 Thursday1,
70 Friday1,
72 Saturday1,
74 Sunday1,
76}
77
78impl Any for WeekdayMethod {
79 fn formula(&self, buf: &mut String) {
80 buf.push_str(match self {
81 WeekdayMethod::Monday0 => "3",
82 WeekdayMethod::Monday1 => "11",
83 WeekdayMethod::Tuesday1 => "12",
84 WeekdayMethod::Wednesday1 => "13",
85 WeekdayMethod::Thursday1 => "14",
86 WeekdayMethod::Friday1 => "15",
87 WeekdayMethod::Saturday1 => "16",
88 WeekdayMethod::Sunday1 => "17",
89 });
90 }
91}
92
93#[derive(Debug)]
95pub enum WeeknumMethod {
96 Jan1WeekMonday,
98 Jan1WeekTuesday,
100 Jan1WeekWednesday,
102 Jan1WeekThursday,
104 Jan1WeekFriday,
106 Jan1WeekSaturday,
108 Jan1WeekSunday,
110 ISOWeeknum,
112}
113
114impl Any for WeeknumMethod {
115 fn formula(&self, buf: &mut String) {
116 buf.push_str(match self {
117 WeeknumMethod::Jan1WeekMonday => "11",
118 WeeknumMethod::Jan1WeekTuesday => "12",
119 WeeknumMethod::Jan1WeekWednesday => "13",
120 WeeknumMethod::Jan1WeekThursday => "14",
121 WeeknumMethod::Jan1WeekFriday => "15",
122 WeeknumMethod::Jan1WeekSaturday => "16",
123 WeeknumMethod::Jan1WeekSunday => "17",
124 WeeknumMethod::ISOWeeknum => "21",
125 });
126 }
127}
128
129#[derive(Debug)]
131pub enum YearFracMethod {
132 USNasd30_360,
134 ActualActual,
136 Actual360,
138 Actual365,
140 European30_360,
142}
143
144impl Any for YearFracMethod {
145 fn formula(&self, buf: &mut String) {
146 buf.push_str(match self {
147 YearFracMethod::USNasd30_360 => "0",
148 YearFracMethod::ActualActual => "1",
149 YearFracMethod::Actual360 => "2",
150 YearFracMethod::Actual365 => "3",
151 YearFracMethod::European30_360 => "4",
152 });
153 }
154}