summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/iter/masks.rs519
-rw-r--r--src/iter/mod.rs12
2 files changed, 386 insertions, 145 deletions
diff --git a/src/iter/masks.rs b/src/iter/masks.rs
index d789d00..970c570 100644
--- a/src/iter/masks.rs
+++ b/src/iter/masks.rs
@@ -4,152 +4,387 @@
// Every mask is 7 days longer to handle cross-year weekly periods.
-lazy_static! {
- pub static ref MASKS: Masks = Masks::default();
-}
+const WDAY: [[usize; 7]; 55] = [[0, 1, 2, 3, 4, 5, 6]; 55];
+const M365: [usize; 365 + 7] = [
+ // 31
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ // 28
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ // 31
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ // 30
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ // 31
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ // 30
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ // 31
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ // 31
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ // 30
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ // 31
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10,
+ // 30 -----------------------------------------------------------------------------------------
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 11, 11,
+ // 31 -----------------------------------------------------------------------------------------
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12,
+ // 7 ------------------------------------------------------------------------------------------
+ 1, 1, 1, 1, 1, 1, 1,
+];
+const MDAY365: [usize; 365 + 7] = [
+ // 31
+ 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,
+ // 28 -----------------------------------------------------------------------------------------
+ 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,
+ // 31 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 31 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 -----------------------------------------------------------------------------------------
+ 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 -----------------------------------------------------------------------------------------
+ 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,
+ // 7 -----------------------------------------------------------------------------------------
+ 1, 2, 3, 4, 5, 6, 7,
+];
+const NMDAY365: [isize; 365 + 7] = [
+ // 31
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 28 -----------------------------------------------------------------------------------------
+ -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10,
+ -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 -----------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 -----------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 7 -----------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25,
+];
+const M365_RANGE: [usize; 13] = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
+
+const M366: [usize; 366 + 7] = [
+ // 31
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ // 29
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ // 31
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ // 30
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ // 31
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ // 30
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ // 31
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ // 31
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ // 30
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ // 31
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10,
+ // 30 -----------------------------------------------------------------------------------------
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 11, 11,
+ // 31 -----------------------------------------------------------------------------------------
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12,
+ // 7 ------------------------------------------------------------------------------------------
+ 1, 1, 1, 1, 1, 1, 1,
+];
+const MDAY366: [usize; 366 + 7] = [
+ // 31
+ 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,
+ // 29 -----------------------------------------------------------------------------------------
+ 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,
+ // 31 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 31 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 ---------------------------------------------------------------------------------------
+ 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 ---------------------------------------------------------------------------------------
+ 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,
+ // 30 -----------------------------------------------------------------------------------------
+ 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 -----------------------------------------------------------------------------------------
+ 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,
+ // 7 -----------------------------------------------------------------------------------------
+ 1, 2, 3, 4, 5, 6, 7,
+];
+const M366_RANGE: [usize; 13] = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
+const NMDAY366: [isize; 366 + 7] = [
+ // 31
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 29 -----------------------------------------------------------------------------------------
+ -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
+ -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 ---------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 ---------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 30 -----------------------------------------------------------------------------------------
+ -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12,
+ -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 31 -----------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
+ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
+ // 7 -----------------------------------------------------------------------------------------
+ -31, -30, -29, -28, -27, -26, -25,
+];
#[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>,
+ pub wday: [[usize; 7]; 55],
+ pub m365: [usize; 365 + 7],
+ pub m365range: [usize; 13],
+ pub m366: [usize; 366 + 7],
+ pub m366range: [usize; 13],
+ pub mday365: [usize; 365 + 7],
+ pub mday366: [usize; 366 + 7],
+ pub nmday365: [isize; 365 + 7],
+ pub nmday366: [isize; 366 + 7],
}
-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();
+pub const MASKS: Masks = Masks {
+ wday: WDAY,
+ m365: M365,
+ m365range: M365_RANGE,
+ m366: M366,
+ m366range: M366_RANGE,
+ mday365: MDAY365,
+ mday366: MDAY366,
+ nmday365: NMDAY365,
+ nmday366: NMDAY366,
+};
- 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();
+// 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();
- 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(),
- }
- }
-}
+// 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(),
+// }
+// }
+// }
diff --git a/src/iter/mod.rs b/src/iter/mod.rs
index efec2ca..2d78bab 100644
--- a/src/iter/mod.rs
+++ b/src/iter/mod.rs
@@ -156,8 +156,13 @@ pub fn increment_counter_date(
}
pub fn is_filtered(ii: &IterInfo, current_day: usize, options: &ParsedOptions) -> bool {
- return (not_empty(&options.bymonth)
- && !includes(&options.bymonth, &ii.mmask().unwrap()[current_day]))
+ if !options.bymonth.is_empty() {
+ println!("Current day: {}", current_day);
+ println!("Byymonth: {:?}", options.bymonth);
+ println!("mask: {:?}", ii.mmask().unwrap());
+ }
+ return (!options.bymonth.is_empty()
+ && !options.bymonth.contains(&ii.mmask().unwrap()[current_day]))
|| (not_empty(&options.byweekno) && (ii.wnomask().unwrap()[current_day]) == 0)
|| (not_empty(&options.byweekday)
&& !includes(&options.byweekday, &ii.wdaymask().unwrap()[current_day]))
@@ -217,7 +222,8 @@ pub fn build_timeset(options: &ParsedOptions) -> Vec<Time> {
return vec![];
}
- let mut timeset = vec![];
+ let mut timeset =
+ Vec::with_capacity(options.byhour.len() * options.byminute.len() * options.bysecond.len());
for hour in &options.byhour {
for minute in &options.byminute {
for second in &options.bysecond {