summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-10-17 19:52:44 +0200
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-10-17 19:52:44 +0200
commit7f90c6abb134490f2e55471a96128f632588f445 (patch)
tree19d492a43f34987805d3553baa38b470f284313e /src
parentfdacd3669bbc4dc0d80dd81fc6b241c0b97a2116 (diff)
downloadrust_rrule-7f90c6abb134490f2e55471a96128f632588f445.zip
negative month day tests and support
Diffstat (limited to 'src')
-rw-r--r--src/iter.rs6
-rw-r--r--src/iterinfo.rs2
-rw-r--r--src/masks.rs6
-rw-r--r--src/options.rs8
-rw-r--r--src/yearinfo.rs4
5 files changed, 11 insertions, 15 deletions
diff --git a/src/iter.rs b/src/iter.rs
index 59c9c96..70c3938 100644
--- a/src/iter.rs
+++ b/src/iter.rs
@@ -257,7 +257,6 @@ pub fn increment_counter_date(
Frequenzy::HOURLY => {
let mut new_hours = counter_date.hour() as usize;
if filtered {
- println!("yeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah");
new_hours += ((23 - new_hours) as f32 / options.interval as f32).floor() as usize
* options.interval;
}
@@ -270,7 +269,6 @@ pub fn increment_counter_date(
.iter()
.any(|bh| *bh == (new_hours % 24) as usize)
{
- println!("Broke at new hours: {}", new_hours);
break;
}
}
@@ -293,10 +291,6 @@ pub fn not_empty<T>(v: &Vec<T>) -> bool {
}
pub fn is_filtered(ii: &IterInfo, current_day: usize, options: &ParsedOptions) -> bool {
- //println!(
- //"Filtered here: {}",
- //(not_empty(&options.byweekno) && (ii.wnomask().unwrap()[current_day]) == 0)
- //);
return (not_empty(&options.bymonth)
&& !includes(&options.bymonth, &ii.mmask().unwrap()[current_day]))
|| (not_empty(&options.byweekno) && (ii.wnomask().unwrap()[current_day]) == 0)
diff --git a/src/iterinfo.rs b/src/iterinfo.rs
index ef1cded..c0285f6 100644
--- a/src/iterinfo.rs
+++ b/src/iterinfo.rs
@@ -120,7 +120,7 @@ impl<'a> IterInfo<'a> {
None => None,
}
}
- pub fn mdaymask(&self) -> Option<&Vec<usize>> {
+ pub fn mdaymask(&self) -> Option<&Vec<isize>> {
match &self.yearinfo {
Some(info) => Some(&info.mdaymask),
None => None,
diff --git a/src/masks.rs b/src/masks.rs
index 59d4ee1..8b2f6b0 100644
--- a/src/masks.rs
+++ b/src/masks.rs
@@ -15,8 +15,8 @@ pub struct Masks {
pub m365range: Vec<usize>,
pub m366: Vec<usize>,
pub m366range: Vec<usize>,
- pub mday365: Vec<usize>,
- pub mday366: Vec<usize>,
+ pub mday365: Vec<isize>,
+ pub mday366: Vec<isize>,
pub nmday365: Vec<isize>,
pub nmday366: Vec<isize>,
}
@@ -74,6 +74,7 @@ impl Default for Masks {
]
.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![
@@ -93,6 +94,7 @@ impl Default for Masks {
]
.into_iter()
.flatten()
+ .map(|d| d as isize)
.collect(),
m366: vec![
vec![1; 31],
diff --git a/src/options.rs b/src/options.rs
index 14712a5..59f1c43 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -8,7 +8,7 @@ pub struct YearInfo {
pub yearweekday: usize,
pub mmask: Vec<usize>,
pub mrange: Vec<usize>,
- pub mdaymask: Vec<usize>,
+ pub mdaymask: Vec<isize>,
pub nmdaymask: Vec<isize>,
pub wdaymask: Vec<usize>,
pub wnomask: Option<Vec<usize>>,
@@ -36,7 +36,7 @@ pub struct ParsedOptions {
pub wkst: usize,
pub bysetpos: Vec<isize>,
pub bymonth: Vec<usize>,
- pub bymonthday: Vec<usize>,
+ pub bymonthday: Vec<isize>,
pub bynmonthday: Vec<isize>,
pub byyearday: Vec<isize>,
pub byweekno: Vec<isize>,
@@ -60,7 +60,7 @@ impl ParsedOptions {
wkst: 0,
bysetpos: vec![],
bymonth: vec![dtstart.month() as usize],
- bymonthday: vec![dtstart.day() as usize],
+ bymonthday: vec![dtstart.day() as isize],
bynmonthday: vec![],
byyearday: vec![],
byweekno: vec![],
@@ -109,7 +109,7 @@ impl ParsedOptions {
self.bymonth = bymonth;
self
}
- pub fn bymonthday(mut self, bymonthday: Vec<usize>) -> Self {
+ pub fn bymonthday(mut self, bymonthday: Vec<isize>) -> Self {
self.bymonthday = bymonthday;
self
}
diff --git a/src/yearinfo.rs b/src/yearinfo.rs
index f50267a..8d7fd4b 100644
--- a/src/yearinfo.rs
+++ b/src/yearinfo.rs
@@ -1,7 +1,7 @@
use crate::masks::MASKS;
use crate::options::*;
use chrono::prelude::*;
-use chrono::{DateTime};
+use chrono::DateTime;
fn is_leap_year(year: i32) -> bool {
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
@@ -32,7 +32,7 @@ pub fn get_weekday_val(wk: &Weekday) -> usize {
pub struct BaseMasks {
mmask: Vec<usize>,
- mdaymask: Vec<usize>,
+ mdaymask: Vec<isize>,
nmdaymask: Vec<isize>,
wdaymask: Vec<usize>,
mrange: Vec<usize>,