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
155
|
use once_cell::sync::Lazy;
// =============================================================================
// Date masks
// =============================================================================
// Every mask is 7 days longer to handle cross-year weekly periods.
pub static MASKS: Lazy<Masks> = Lazy::new(Masks::default);
#[derive(Clone)]
pub struct Masks {
pub wday: Vec<usize>,
pub m365: Vec<usize>,
pub m365range: Vec<usize>,
pub m366: Vec<usize>,
pub m366range: Vec<usize>,
pub mday365: Vec<isize>,
pub mday366: Vec<isize>,
pub nmday365: Vec<isize>,
pub nmday366: Vec<isize>,
}
impl Default for Masks {
fn default() -> Self {
let m28: Vec<usize> = (1..29).collect();
let m29: Vec<usize> = (1..30).collect();
let m30: Vec<usize> = (1..31).collect();
let m31: Vec<usize> = (1..32).collect();
let nm28: Vec<isize> = (-28..0).collect();
let nm29: Vec<isize> = (-29..0).collect();
let nm30: Vec<isize> = (-30..0).collect();
let nm31: Vec<isize> = (-31..0).collect();
Self {
wday: vec![(0..7).collect::<Vec<usize>>(); 55]
.into_iter()
.flatten()
.collect(),
m365: vec![
vec![1; 31],
vec![2; 28],
vec![3; 31],
vec![4; 30],
vec![5; 31],
vec![6; 30],
vec![7; 31],
vec![8; 31],
vec![9; 30],
vec![10; 31],
vec![11; 30],
vec![12; 31],
vec![1; 7],
]
.into_iter()
.flatten()
.collect(),
m365range: vec![0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365],
mday366: vec![
m31.clone(),
m29,
m31.clone(),
m30.clone(),
m31.clone(),
m30.clone(),
m31.clone(),
m31.clone(),
m30.clone(),
m31.clone(),
m30.clone(),
m31.clone(),
Vec::from(&m31[0..7]),
]
.into_iter()
.flatten()
.map(|d| d as isize)
.collect(),
m366range: vec![0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366],
mday365: vec![
m31.clone(),
m28,
m31.clone(),
m30.clone(),
m31.clone(),
m30.clone(),
m31.clone(),
m31.clone(),
m30.clone(),
m31.clone(),
m30,
m31.clone(),
Vec::from(&m31[0..7]),
]
.into_iter()
.flatten()
.map(|d| d as isize)
.collect(),
m366: vec![
vec![1; 31],
vec![2; 29],
vec![3; 31],
vec![4; 30],
vec![5; 31],
vec![6; 30],
vec![7; 31],
vec![8; 31],
vec![9; 30],
vec![10; 31],
vec![11; 30],
vec![12; 31],
vec![1; 7],
]
.into_iter()
.flatten()
.collect(),
nmday365: vec![
nm31.clone(),
nm28,
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm30.clone(),
nm31.clone(),
Vec::from(&nm31[0..7]),
]
.into_iter()
.flatten()
.collect(),
nmday366: vec![
nm31.clone(),
nm29,
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm31.clone(),
nm30.clone(),
nm31.clone(),
nm30,
nm31.clone(),
Vec::from(&nm31[0..7]),
]
.into_iter()
.flatten()
.collect(),
}
}
}
|