diff options
-rw-r--r-- | src/iter.rs | 13 | ||||
-rw-r--r-- | src/yearinfo.rs | 4 | ||||
-rw-r--r-- | tests/rrule.rs | 72 |
3 files changed, 74 insertions, 15 deletions
diff --git a/src/iter.rs b/src/iter.rs index b9c1560..daa67c2 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -108,7 +108,6 @@ pub fn iter(iter_result: &mut IterResult, options: &mut ParsedOptions) -> Vec<Da }; loop { - println!("Main loop"); let (dayset, start, end) = ii.getdayset( &options.freq, counter_date.year() as isize, @@ -120,10 +119,8 @@ pub fn iter(iter_result: &mut IterResult, options: &mut ParsedOptions) -> Vec<Da .into_iter() .map(|s| Some(s as isize)) .collect::<Vec<Option<isize>>>(); - println!("dayset: {:?}", dayset); let filtered = remove_filtered_days(&mut dayset, start, end, &ii, options); - println!("dayset: {:?}", dayset); if not_empty(&options.bysetpos) { let poslist = build_poslist(&options.bysetpos, ×et, start, end, &ii, &dayset); @@ -150,7 +147,6 @@ pub fn iter(iter_result: &mut IterResult, options: &mut ParsedOptions) -> Vec<Da } } } else { - println!("start: {}, end: {}", start, end); for j in start..end { let current_day = dayset[j]; if current_day.is_none() { @@ -159,7 +155,6 @@ pub fn iter(iter_result: &mut IterResult, options: &mut ParsedOptions) -> Vec<Da let current_day = current_day.unwrap(); let date = from_ordinal(ii.yearordinal().unwrap() + current_day); - println!("timeset: {}", timeset.len()); for k in 0..timeset.len() { let res = Utc.ymd(date.year(), date.month(), date.day()).and_hms( timeset[k].hour as u32, @@ -270,10 +265,10 @@ pub fn not_empty<T>(v: &Vec<T>) -> bool { } pub fn is_filtered(ii: &IterInfo, current_day: usize, options: &ParsedOptions) -> bool { - println!( - "Was filtered here: {}", - (not_empty(&options.byweekno) && (ii.wnomask().unwrap()[current_day]) == 0) - ); + //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/yearinfo.rs b/src/yearinfo.rs index a2cd972..5ae6340 100644 --- a/src/yearinfo.rs +++ b/src/yearinfo.rs @@ -115,7 +115,7 @@ pub fn rebuild_year(year: i32, options: &ParsedOptions) -> YearInfo { } let div = (wyearlen as f32 / 7.).round() as isize; - let year_mod = pymod(div, 7); + let year_mod = pymod(wyearlen, 7); //const numweeks = Math.floor(div + mod / 4) let numweeks = div + (year_mod / 4); @@ -174,7 +174,7 @@ pub fn rebuild_year(year: i32, options: &ParsedOptions) -> YearInfo { // days from last year's last week number in // this year. let lnumweeks; - if options.byweekno.iter().any(|&weekno| weekno == -1) { + if !options.byweekno.iter().any(|&weekno| weekno == -1) { let lyearweekday = get_weekday_val(&Utc.ymd(year - 1, 1, 1).weekday()); let lno1wkst = pymod((7 - lyearweekday + options.wkst) as isize, 7); diff --git a/tests/rrule.rs b/tests/rrule.rs index 3691fbb..967e337 100644 --- a/tests/rrule.rs +++ b/tests/rrule.rs @@ -565,10 +565,10 @@ mod test { count: Some(3), bymonth: vec![], dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), - byweekday: vec![20], + byweekday: vec![], byhour: vec![9], bysetpos: vec![], - byweekno: vec![], + byweekno: vec![20], byminute: vec![0], bysecond: vec![0], byyearday: vec![], @@ -584,8 +584,72 @@ mod test { &mut options, &vec![ ymd_hms(1998, 5, 11, 9, 0, 0), - ymd_hms(1999, 5, 12, 9, 0, 0), - ymd_hms(1999, 5, 13, 9, 0, 0), + ymd_hms(1998, 5, 12, 9, 0, 0), + ymd_hms(1998, 5, 13, 9, 0, 0), + ], + ); + } + + #[test] + fn yearly_by_weekno_and_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::YEARLY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![0], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![1], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 29, 9, 0, 0), + ymd_hms(1999, 1, 4, 9, 0, 0), + ymd_hms(2000, 1, 3, 9, 0, 0), + ], + ); + } + + #[test] + fn yearly_by_weekno_and_weekday_large() { + let mut options = ParsedOptions { + freq: Frequenzy::YEARLY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![6], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![52], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 28, 9, 0, 0), + ymd_hms(1998, 12, 27, 9, 0, 0), + ymd_hms(2000, 1, 2, 9, 0, 0), ], ); } |