diff options
author | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-12-16 16:32:26 +0100 |
---|---|---|
committer | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-12-16 16:32:26 +0100 |
commit | 2c70b134b5d6bd8a49749fed348ae0e6958f8455 (patch) | |
tree | 4b6024c8795071f5984e59287cdd65169a4ce1b5 /src/options.rs | |
parent | 0060c162120c96dabbd78113c29d516d83828f14 (diff) | |
download | rust_rrule-2c70b134b5d6bd8a49749fed348ae0e6958f8455.zip |
numeric identifier when n=1 bug
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/options.rs b/src/options.rs index ac35315..7f291bc 100644 --- a/src/options.rs +++ b/src/options.rs @@ -17,19 +17,25 @@ pub enum Frequenzy { Secondly = 6, } +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum NWeekdayIdentifier { + Every, + Identifier(isize), +} + #[derive(Copy, Clone, Debug)] pub struct NWeekday { pub weekday: usize, - pub n: isize, + pub n: NWeekdayIdentifier, } impl NWeekday { - pub fn new(weekday: usize, n: isize) -> Self { + pub fn new(weekday: usize, n: NWeekdayIdentifier) -> Self { // if (n === 0) throw new Error("Can't create weekday with n == 0") Self { weekday, n } } - pub fn from(weekday: &Weekday, n: isize) -> Self { + pub fn from(weekday: &Weekday, n: NWeekdayIdentifier) -> Self { // if (n === 0) throw new Error("Can't create weekday with n == 0") Self { weekday: get_weekday_val(weekday), @@ -37,7 +43,7 @@ impl NWeekday { } } - pub fn nth(&self, n: isize) -> Self { + pub fn nth(&self, n: NWeekdayIdentifier) -> Self { if self.n == n { return self.clone(); } @@ -235,7 +241,7 @@ impl Options { let byweekday = byweekday .iter() .map(|w| get_weekday_val(w)) - .map(|w| NWeekday::new(w, 1)) + .map(|w| NWeekday::new(w, NWeekdayIdentifier::Every)) .collect(); self.byweekday = Some(byweekday); self |