diff options
Diffstat (limited to 'src/iter/yearinfo.rs')
-rw-r--r-- | src/iter/yearinfo.rs | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/src/iter/yearinfo.rs b/src/iter/yearinfo.rs index 8a944f7..40b48ce 100644 --- a/src/iter/yearinfo.rs +++ b/src/iter/yearinfo.rs @@ -1,7 +1,8 @@ -use crate::masks::MASKS; +use crate::iter::masks::MASKS; use crate::options::*; use chrono::prelude::*; -use crate::datetime::to_ordinal; +use crate::datetime::{to_ordinal, get_year_len, get_weekday_val}; +use crate::iter::utils::pymod; #[derive(Debug)] @@ -18,29 +19,6 @@ pub struct YearInfo { pub wnomask: Option<Vec<usize>>, } -fn is_leap_year(year: i32) -> bool { - year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) -} - -fn get_year_len(year: i32) -> usize { - if is_leap_year(year) { - return 366; - } - 365 -} - -pub fn get_weekday_val(wk: &Weekday) -> usize { - match wk { - Weekday::Mon => 0, - Weekday::Tue => 1, - Weekday::Wed => 2, - Weekday::Thu => 3, - Weekday::Fri => 4, - Weekday::Sat => 5, - Weekday::Sun => 6, - } -} - pub struct BaseMasks { mmask: Vec<usize>, mdaymask: Vec<isize>, @@ -74,15 +52,6 @@ fn base_year_masks(year: i32) -> BaseMasks { } } -pub fn pymod(a: isize, b: isize) -> isize { - let r = a % b; - // If r and b differ in sign, add b to wrap the result to the correct sign. - if (r > 0 && b < 0) || (r < 0 && b > 0) { - return r + b; - } - r -} - pub fn rebuild_year(year: i32, options: &ParsedOptions) -> YearInfo { let firstyday = Utc.ymd(year, 1, 1).and_hms_milli(0, 0, 0, 0); |