summaryrefslogtreecommitdiff
path: root/src/iter
diff options
context:
space:
mode:
Diffstat (limited to 'src/iter')
-rw-r--r--src/iter/iterinfo.rs8
-rw-r--r--src/iter/mod.rs44
-rw-r--r--src/iter/monthinfo.rs2
-rw-r--r--src/iter/poslist.rs11
-rw-r--r--src/iter/utils.rs2
-rw-r--r--src/iter/yearinfo.rs5
6 files changed, 37 insertions, 35 deletions
diff --git a/src/iter/iterinfo.rs b/src/iter/iterinfo.rs
index 1d401dd..7c47645 100644
--- a/src/iter/iterinfo.rs
+++ b/src/iter/iterinfo.rs
@@ -1,8 +1,8 @@
-use crate::datetime::{Time, to_ordinal};
+use crate::datetime::{to_ordinal, Time};
use crate::iter::easter::easter;
-use crate::iter::monthinfo::{MonthInfo, rebuild_month};
-use crate::iter::yearinfo::{YearInfo, rebuild_year};
-use crate::options::{ParsedOptions, Frequenzy};
+use crate::iter::monthinfo::{rebuild_month, MonthInfo};
+use crate::iter::yearinfo::{rebuild_year, YearInfo};
+use crate::options::{Frequenzy, ParsedOptions};
use chrono::prelude::*;
pub struct IterInfo<'a> {
diff --git a/src/iter/mod.rs b/src/iter/mod.rs
index 8e0d4a5..790ef67 100644
--- a/src/iter/mod.rs
+++ b/src/iter/mod.rs
@@ -1,6 +1,6 @@
-mod yearinfo;
-mod monthinfo;
mod iterinfo;
+mod monthinfo;
+mod yearinfo;
use iterinfo::IterInfo;
mod poslist;
use poslist::build_poslist;
@@ -8,8 +8,8 @@ mod easter;
mod masks;
mod utils;
+use crate::datetime::{from_ordinal, get_weekday_val, DTime, Time};
use crate::options::*;
-use crate::datetime::{Time, DTime, from_ordinal, get_weekday_val};
use chrono::offset::TimeZone;
use chrono::prelude::*;
use chrono::Duration;
@@ -19,11 +19,7 @@ pub trait IterResult {
fn get_value(&self) -> Vec<DTime>;
}
-pub fn iter<T: IterResult>(
- iter_result: &mut T,
- options: &mut ParsedOptions,
-) -> Vec<DTime> {
-
+pub fn iter<T: IterResult>(iter_result: &mut T, options: &mut ParsedOptions) -> Vec<DTime> {
if (options.count.is_some() && options.count.unwrap() == 0) || options.interval == 0 {
return iter_result.get_value();
}
@@ -54,7 +50,15 @@ pub fn iter<T: IterResult>(
let filtered = remove_filtered_days(&mut dayset, start, end, &ii, options);
if not_empty(&options.bysetpos) {
- let poslist = build_poslist(&options.bysetpos, &timeset, start, end, &ii, &dayset, &options.tzid);
+ let poslist = build_poslist(
+ &options.bysetpos,
+ &timeset,
+ start,
+ end,
+ &ii,
+ &dayset,
+ &options.tzid,
+ );
for j in 0..poslist.len() {
let res = poslist[j];
@@ -85,11 +89,14 @@ pub fn iter<T: IterResult>(
let current_day = current_day.unwrap();
let date = from_ordinal(ii.yearordinal().unwrap() + current_day, &options.tzid);
for k in 0..timeset.len() {
- let res = options.tzid.ymd(date.year(), date.month(), date.day()).and_hms(
- timeset[k].hour as u32,
- timeset[k].minute as u32,
- timeset[k].second as u32,
- );
+ let res = options
+ .tzid
+ .ymd(date.year(), date.month(), date.day())
+ .and_hms(
+ timeset[k].hour as u32,
+ timeset[k].minute as u32,
+ timeset[k].second as u32,
+ );
if options.until.is_some() && res > options.until.unwrap() {
return iter_result.get_value();
}
@@ -97,7 +104,7 @@ pub fn iter<T: IterResult>(
if !iter_result.accept(res) {
return iter_result.get_value();
}
-
+
if count > 0 {
count -= 1;
if count == 0 {
@@ -137,7 +144,6 @@ pub fn iter<T: IterResult>(
}
}
-
pub fn increment_counter_date(
counter_date: DTime,
options: &ParsedOptions,
@@ -289,11 +295,7 @@ pub fn build_timeset(options: &ParsedOptions) -> Vec<Time> {
timeset
}
-pub fn make_timeset(
- ii: &IterInfo,
- counter_date: &DTime,
- options: &ParsedOptions,
-) -> Vec<Time> {
+pub fn make_timeset(ii: &IterInfo, counter_date: &DTime, options: &ParsedOptions) -> Vec<Time> {
if options.freq < Frequenzy::Hourly {
return build_timeset(options);
}
diff --git a/src/iter/monthinfo.rs b/src/iter/monthinfo.rs
index 9da2ca6..43fcef8 100644
--- a/src/iter/monthinfo.rs
+++ b/src/iter/monthinfo.rs
@@ -1,5 +1,5 @@
-use crate::options::*;
use crate::iter::utils::pymod;
+use crate::options::*;
#[derive(Debug)]
pub struct MonthInfo {
diff --git a/src/iter/poslist.rs b/src/iter/poslist.rs
index fd564d4..9166073 100644
--- a/src/iter/poslist.rs
+++ b/src/iter/poslist.rs
@@ -1,7 +1,7 @@
-use crate::datetime::{Time, DTime};
+use crate::datetime::from_ordinal;
+use crate::datetime::{DTime, Time};
use crate::iter::iterinfo::IterInfo;
use crate::iter::utils::pymod;
-use crate::datetime::from_ordinal;
use chrono::prelude::*;
use chrono_tz::Tz;
@@ -12,7 +12,7 @@ pub fn build_poslist(
end: usize,
ii: &IterInfo,
dayset: &Vec<Option<isize>>,
- tz: &Tz
+ tz: &Tz,
) -> Vec<DTime> {
let mut poslist = vec![];
@@ -31,8 +31,9 @@ pub fn build_poslist(
let mut tmp = vec![];
for k in start..end {
let val = dayset[k];
- if val.is_some() {
- tmp.push(val.unwrap());
+ match val {
+ Some(v) => tmp.push(v),
+ None => (),
}
}
diff --git a/src/iter/utils.rs b/src/iter/utils.rs
index c168c92..a134d9a 100644
--- a/src/iter/utils.rs
+++ b/src/iter/utils.rs
@@ -5,4 +5,4 @@ pub fn pymod(a: isize, b: isize) -> isize {
return r + b;
}
r
-} \ No newline at end of file
+}
diff --git a/src/iter/yearinfo.rs b/src/iter/yearinfo.rs
index 40b48ce..308a205 100644
--- a/src/iter/yearinfo.rs
+++ b/src/iter/yearinfo.rs
@@ -1,9 +1,8 @@
+use crate::datetime::{get_weekday_val, get_year_len, to_ordinal};
use crate::iter::masks::MASKS;
+use crate::iter::utils::pymod;
use crate::options::*;
use chrono::prelude::*;
-use crate::datetime::{to_ordinal, get_year_len, get_weekday_val};
-use crate::iter::utils::pymod;
-
#[derive(Debug)]
pub struct YearInfo {