diff options
-rw-r--r-- | src/datetime.rs | 12 | ||||
-rw-r--r-- | src/iter/mod.rs | 18 | ||||
-rw-r--r-- | src/iter/poslist.rs | 6 | ||||
-rw-r--r-- | src/options.rs | 11 | ||||
-rw-r--r-- | src/parse_options.rs | 7 | ||||
-rw-r--r-- | src/rruleset.rs | 42 | ||||
-rw-r--r-- | src/rrulestr.rs | 137 | ||||
-rw-r--r-- | tests/rrule.rs | 8 |
8 files changed, 153 insertions, 88 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 69cfb00..46b1643 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -4,12 +4,18 @@ use chrono_tz::Tz; pub type DTime = DateTime<Tz>; -pub fn from_ordinal(ordinal: isize) -> DateTime<Utc> { +// pub fn from_ordinal(ordinal: isize) -> DateTime<Utc> { +// let timestamp = ordinal * 24 * 60 * 60; +// let naive = NaiveDateTime::from_timestamp(timestamp as i64, 0); +// DateTime::from_utc(naive, Utc) +// } + +pub fn from_ordinal(ordinal: isize, tz: &Tz) -> DTime { let timestamp = ordinal * 24 * 60 * 60; - let naive = NaiveDateTime::from_timestamp(timestamp as i64, 0); - DateTime::from_utc(naive, Utc) + tz.timestamp(timestamp as i64, 0) } + pub fn to_ordinal(date: &DateTime<Utc>) -> isize { (date.timestamp() / 60 / 60 / 24) as isize } diff --git a/src/iter/mod.rs b/src/iter/mod.rs index 42cf58f..87b305a 100644 --- a/src/iter/mod.rs +++ b/src/iter/mod.rs @@ -9,21 +9,20 @@ mod masks; mod utils; use crate::options::*; -use crate::datetime::{Time, from_ordinal, get_weekday_val}; +use crate::datetime::{Time, DTime, from_ordinal, get_weekday_val}; use chrono::offset::TimeZone; use chrono::prelude::*; use chrono::{DateTime, Duration}; -use chrono_tz::*; pub trait IterResult { - fn accept(&mut self, date: DateTime<Tz>) -> bool; - fn get_value(&self) -> Vec<DateTime<Tz>>; + fn accept(&mut self, date: DTime) -> bool; + fn get_value(&self) -> Vec<DTime>; } pub fn iter<T: IterResult>( iter_result: &mut T, options: &mut ParsedOptions, -) -> Vec<DateTime<Tz>> { +) -> Vec<DTime> { if (options.count.is_some() && options.count.unwrap() == 0) || options.interval == 0 { return iter_result.get_value(); @@ -87,7 +86,7 @@ pub fn iter<T: IterResult>( } let current_day = current_day.unwrap(); - let date = from_ordinal(ii.yearordinal().unwrap() + current_day); + 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, @@ -106,6 +105,7 @@ pub fn iter<T: IterResult>( if !iter_result.accept(res) { return iter_result.get_value(); } + if count > 0 { count -= 1; if count == 0 { @@ -147,10 +147,10 @@ pub fn iter<T: IterResult>( pub fn increment_counter_date( - counter_date: DateTime<Utc>, + counter_date: DTime, options: &ParsedOptions, filtered: bool, -) -> DateTime<Utc> { +) -> DTime { match options.freq { Frequenzy::Yearly => counter_date .with_year(counter_date.year() + options.interval as i32) @@ -299,7 +299,7 @@ pub fn build_timeset(options: &ParsedOptions) -> Vec<Time> { pub fn make_timeset( ii: &IterInfo, - counter_date: &DateTime<Utc>, + counter_date: &DTime, options: &ParsedOptions, ) -> Vec<Time> { if options.freq < Frequenzy::Hourly { diff --git a/src/iter/poslist.rs b/src/iter/poslist.rs index 421d352..fd564d4 100644 --- a/src/iter/poslist.rs +++ b/src/iter/poslist.rs @@ -1,4 +1,4 @@ -use crate::datetime::*; +use crate::datetime::{Time, DTime}; use crate::iter::iterinfo::IterInfo; use crate::iter::utils::pymod; use crate::datetime::from_ordinal; @@ -13,7 +13,7 @@ pub fn build_poslist( ii: &IterInfo, dayset: &Vec<Option<isize>>, tz: &Tz -) -> Vec<DateTime<Tz>> { +) -> Vec<DTime> { let mut poslist = vec![]; for j in 0..bysetpost.len() { @@ -44,7 +44,7 @@ pub fn build_poslist( i = &tmp[daypos as usize]; } - let date = from_ordinal(ii.yearordinal().unwrap() + i); + let date = from_ordinal(ii.yearordinal().unwrap() + i, tz); let res = tz.ymd(date.year(), date.month(), date.day()).and_hms( timeset[timepos as usize].hour as u32, timeset[timepos as usize].minute as u32, diff --git a/src/options.rs b/src/options.rs index 5599454..e21ed51 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,5 +1,6 @@ use chrono::prelude::*; use chrono_tz::Tz; +use crate::datetime::DTime; #[derive(Debug, PartialEq, PartialOrd, Clone)] pub enum Frequenzy { @@ -17,9 +18,9 @@ pub struct ParsedOptions { pub freq: Frequenzy, pub interval: usize, pub count: Option<u32>, - pub until: Option<DateTime<Utc>>, + pub until: Option<DTime>, pub tzid: Tz, - pub dtstart: DateTime<Utc>, + pub dtstart: DTime, pub wkst: usize, pub bysetpos: Vec<isize>, pub bymonth: Vec<usize>, @@ -41,9 +42,9 @@ pub struct PartialOptions { pub freq: Option<Frequenzy>, pub interval: Option<usize>, pub count: Option<u32>, - pub until: Option<DateTime<Utc>>, - pub tzid: Option<String>, - pub dtstart: Option<DateTime<Utc>>, + pub until: Option<DTime>, + pub tzid: Option<Tz>, + pub dtstart: Option<DTime>, pub wkst: Option<usize>, pub bysetpos: Option<Vec<isize>>, pub bymonth: Option<Vec<usize>>, diff --git a/src/parse_options.rs b/src/parse_options.rs index b7926ef..41208b6 100644 --- a/src/parse_options.rs +++ b/src/parse_options.rs @@ -10,7 +10,7 @@ pub fn parse_options(options: &PartialOptions) -> ParsedOptions { default_partial_options.wkst = Some(0); let tzid: Tz = if options.tzid.is_some() { - options.tzid.clone().unwrap().parse().unwrap() + options.tzid.clone().unwrap() } else { UTC }; @@ -23,7 +23,7 @@ pub fn parse_options(options: &PartialOptions) -> ParsedOptions { let freq = partial_options.freq.unwrap(); if partial_options.dtstart.is_none() { - partial_options.dtstart = Some(Utc::now()); + panic!("Dtstart can not be None"); } if partial_options.wkst.is_none() { @@ -38,7 +38,6 @@ pub fn parse_options(options: &PartialOptions) -> ParsedOptions { } } - if !( partial_options.byweekno.is_some() || is_some_and_not_empty(&partial_options.byweekno) || @@ -61,7 +60,7 @@ pub fn parse_options(options: &PartialOptions) -> ParsedOptions { Frequenzy::Weekly => { partial_options.byweekday = Some(vec![partial_options.dtstart.unwrap().weekday() as usize]); }, - _ => unreachable!("Shouldnt be reached") + _ => () }; } diff --git a/src/rruleset.rs b/src/rruleset.rs index dc9d589..8326f71 100644 --- a/src/rruleset.rs +++ b/src/rruleset.rs @@ -1,16 +1,16 @@ -use crate::iter::{iter, IterResult}; use chrono::prelude::*; use chrono_tz::{Tz, UTC}; use crate::rrule::RRule; +use crate::datetime::DTime; use crate::rruleset_iter::RRuleSetIter; #[derive(Debug)] pub struct RRuleSet { pub rrule: Vec<RRule>, - pub rdate: Vec<DateTime<Utc>>, + pub rdate: Vec<DTime>, pub exrule: Vec<RRule>, - pub exdate: Vec<DateTime<Utc>>, - pub dtstart: Option<DateTime<Utc>>, + pub exdate: Vec<DTime>, + pub dtstart: Option<DTime>, } impl RRuleSet { @@ -32,11 +32,11 @@ impl RRuleSet { self.exrule.push(rrule); } - pub fn rdate(&mut self, rdate: DateTime<Utc>) { + pub fn rdate(&mut self, rdate: DTime) { self.rdate.push(rdate); } - pub fn exdate(&mut self, exdate: DateTime<Utc>) { + pub fn exdate(&mut self, exdate: DTime) { self.exdate.push(exdate); } @@ -88,8 +88,8 @@ mod test_iter_set { hour: u32, minute: u32, second: u32, - ) -> DateTime<Utc> { - Utc.ymd(year, month, day).and_hms(hour, minute, second) + ) -> DTime { + UTC.ymd(year, month, day).and_hms(hour, minute, second) } fn ymd_hms_2( @@ -124,7 +124,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(6), bymonth: vec![], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![1, 3], byhour: vec![9], bysetpos: vec![], @@ -147,7 +147,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(3), bymonth: vec![], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![3], byhour: vec![9], bysetpos: vec![], @@ -217,7 +217,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(3), bymonth: vec![], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![3], byhour: vec![9], bysetpos: vec![], @@ -255,7 +255,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(6), bymonth: vec![], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![1, 3], byhour: vec![9], bysetpos: vec![], @@ -297,7 +297,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(13), bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -321,7 +321,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(10), bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -359,7 +359,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: None, bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -383,7 +383,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(10), bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -417,7 +417,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: None, bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -441,7 +441,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(10), bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -475,7 +475,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: None, bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -499,7 +499,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(10), bymonth: vec![9], - dtstart: Utc.ymd(1997, 9, 2).and_hms(9, 0, 0), + dtstart: UTC.ymd(1997, 9, 2).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], @@ -541,7 +541,7 @@ mod test_iter_set { freq: Frequenzy::Yearly, count: Some(2), bymonth: vec![1], - dtstart: Utc.ymd(1960, 1, 1).and_hms(9, 0, 0), + dtstart: UTC.ymd(1960, 1, 1).and_hms(9, 0, 0), byweekday: vec![], byhour: vec![9], bysetpos: vec![], diff --git a/src/rrulestr.rs b/src/rrulestr.rs index 1584306..ea3081b 100644 --- a/src/rrulestr.rs +++ b/src/rrulestr.rs @@ -1,9 +1,11 @@ use crate::options::*; use crate::parse_options::parse_options; use crate::rrule::RRule; +use crate::datetime::DTime; use crate::rruleset::RRuleSet; use chrono::prelude::*; use chrono::DateTime; +use chrono_tz::{UTC, Tz}; use once_cell::sync::Lazy; use regex::Regex; @@ -16,9 +18,33 @@ static RRULE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)^(?:RRULE|EXRULE):" -fn datestring_to_date(dt: &str) -> DateTime<Utc> { +fn datestring_to_date(dt: &str, tz: &Tz) -> DTime { let bits = DATESTR_RE.captures(dt).unwrap(); - return Utc + println!("Bits: {:?}", bits); + let t = tz + .ymd( + bits.get(1).unwrap().as_str().parse::<i32>().unwrap(), + bits.get(2).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(3).unwrap().as_str().parse::<u32>().unwrap(), + ) + .and_hms( + bits.get(5).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(6).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(7).unwrap().as_str().parse::<u32>().unwrap(), + ); + let u = UTC + .ymd( + bits.get(1).unwrap().as_str().parse::<i32>().unwrap(), + bits.get(2).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(3).unwrap().as_str().parse::<u32>().unwrap(), + ) + .and_hms( + bits.get(5).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(6).unwrap().as_str().parse::<u32>().unwrap(), + bits.get(7).unwrap().as_str().parse::<u32>().unwrap(), + ); + println!("Diiference : {}", t.timestamp_millis() - u.timestamp_millis()); + return tz .ymd( bits.get(1).unwrap().as_str().parse::<i32>().unwrap(), bits.get(2).unwrap().as_str().parse::<u32>().unwrap(), @@ -31,20 +57,35 @@ fn datestring_to_date(dt: &str) -> DateTime<Utc> { ); } +struct ParsedDateParam { + datetime: DateTime<Tz>, + timezone: Tz, +} + +fn parse_date_param(s: &str, reg: Lazy<Regex>) -> ParsedDateParam { + let caps = reg.captures(s); + + ParsedDateParam { + datetime: UTC.timestamp_nanos(0), + timezone: UTC + } +} + fn parse_dtstart(s: &str) -> Option<PartialOptions> { let caps = DTSTART_RE.captures(s); - println!("captures -----------------------"); - println!("{:?}", caps); + match caps { Some(caps) => { - let mut options = PartialOptions::new(); - options.dtstart = Some(datestring_to_date(caps.get(2).unwrap().as_str())); - options.tzid = if let Some(tzid) = caps.get(1) { - Some(String::from(tzid.as_str())) + let tzid: Tz = if let Some(tzid) = caps.get(1) { + String::from(tzid.as_str()).parse().unwrap_or(UTC) } else { - Some(String::from("UTC")) + UTC }; + + let mut options = PartialOptions::new(); + options.dtstart = Some(datestring_to_date(caps.get(2).unwrap().as_str(), &tzid)); + options.tzid = Some(tzid); Some(options) } None => None, @@ -71,14 +112,15 @@ fn parse_rrule(line: &str) -> PartialOptions { line }; - + println!("Stripped line: {}", stripped_line); let mut options = parse_dtstart(stripped_line).unwrap_or(PartialOptions::new()); + println!("Options from dtstart: {:?}", options); let attrs = RRULE_RE.replace(line, ""); let attrs = attrs.split(";"); for attr in attrs { - println!("Attr: {}", attr); + let l: Vec<&str> = attr.split("=").collect(); let key = l[0]; @@ -86,7 +128,7 @@ fn parse_rrule(line: &str) -> PartialOptions { if l.len() > 1 { value = l[1]; } - println!("Ket: {}", key); + match key.to_uppercase().as_str() { "FREQ" => { options.freq = Some(from_str_to_freq(value).unwrap()); @@ -138,13 +180,12 @@ fn parse_rrule(line: &str) -> PartialOptions { "DTSTART" | "TZID" => { // for backwards compatibility let dtstart_opts = parse_dtstart(line).unwrap(); - println!("After parsing tzid"); - println!("{:?}", dtstart_opts); options.tzid = Some(dtstart_opts.tzid.unwrap()); options.dtstart = Some(dtstart_opts.dtstart.unwrap()); } "UNTIL" => { - options.until = Some(datestring_to_date(value)); + // Until is always in UTC + options.until = Some(datestring_to_date(value, &UTC)); } "BYEASTER" => { options.byeaster = Some(value.parse::<isize>().unwrap()); @@ -189,6 +230,7 @@ fn parse_weekday(val: &str) -> Vec<usize> { } fn parse_line(rfc_string: &str) -> Option<PartialOptions> { + println!("Parse line: {}", rfc_string); let re = Regex::new(r"(?m)^\s+|\s+$").unwrap(); let rfc_string = re.replace(rfc_string, ""); if rfc_string.is_empty() { @@ -262,8 +304,6 @@ fn parse_string(rfc_string: &str) -> PartialOptions { .collect(); if options.len() == 1 { - println!("Options i got from str: {}", rfc_string); - println!("{:?}", options[0]); return options[0].clone(); } @@ -273,11 +313,11 @@ fn parse_string(rfc_string: &str) -> PartialOptions { #[derive(Debug)] struct ParsedInput { rrule_vals: Vec<PartialOptions>, - rdate_vals: Vec<DateTime<Utc>>, + rdate_vals: Vec<DTime>, exrule_vals: Vec<PartialOptions>, - exdate_vals: Vec<DateTime<Utc>>, - dtstart: Option<DateTime<Utc>>, - tzid: Option<String>, + exdate_vals: Vec<DTime>, + dtstart: Option<DTime>, + tzid: Option<Tz>, } fn parse_input(s: &str) -> ParsedInput { @@ -288,12 +328,13 @@ fn parse_input(s: &str) -> ParsedInput { let PartialOptions { dtstart, - mut tzid, + tzid, .. } = parse_dtstart(s).unwrap(); let lines: Vec<&str> = s.split("\n").collect(); + println!("Lines: {:?}", lines); for line in &lines { let parsed_line = break_down_line(line); match parsed_line.name.to_uppercase().as_str() { @@ -307,20 +348,35 @@ fn parse_input(s: &str) -> ParsedInput { rrule_vals.push(parse_string(line)); } + "EXRULE" => { + if !parsed_line.params.is_empty() { + panic!("Unsupported EXRULE value"); + } + if parsed_line.value.is_empty() { + continue; + } + + exrule_vals.push(parse_string(&parsed_line.value)); + } "RDATE" => { let re = Regex::new(r"(?m)RDATE(?:;TZID=([^:=]+))?").unwrap(); let matches = re.captures(line).unwrap(); - if tzid.is_none() && matches.get(1).is_some() { - tzid = Some(String::from(matches.get(1).unwrap().as_str())); + let mut tz = UTC; + if let Some(tzid) = matches.get(1) { + tz = String::from(tzid.as_str()).parse().unwrap_or(UTC); } - rdate_vals.append(&mut parse_rdate(&parsed_line.value, parsed_line.params)); - } - "EXRULE" => { - exrule_vals.push(parse_string(&parsed_line.value)); + rdate_vals.append(&mut parse_rdate(&parsed_line.value, parsed_line.params, &tz)); } "EXDATE" => { - exdate_vals.append(&mut parse_rdate(&parsed_line.value, parsed_line.params)); + let re = Regex::new(r"(?m)EXDATE(?:;TZID=([^:=]+))?").unwrap(); + let matches = re.captures(line).unwrap(); + let tz: Tz = if let Some(tzid) = matches.get(1) { + String::from(tzid.as_str()).parse().unwrap_or(UTC) + } else { + UTC + }; + exdate_vals.append(&mut parse_rdate(&parsed_line.value, parsed_line.params, &tz)); } "DTSTART" => (), _ => panic!("Unsupported property: {}", parsed_line.name) @@ -347,11 +403,16 @@ fn validate_date_param(params: Vec<&str>){ } } -fn parse_rdate(rdateval: &str, params: Vec<String>) -> Vec<DateTime<Utc>> { +// ! works needs to be done here +fn parse_rdate(rdateval: &str, params: Vec<String>, tz: &Tz) -> Vec<DTime> { let params: Vec<&str> = params.iter().map(|p| p.as_str()).collect(); validate_date_param(params); + // let re_timezone = Regex::new(r"(?m)TZID=(.+):").unwrap(); + // let caps = re_timezone.captures(text) + // let tzid = re_timezone - rdateval.split(",").map(|datestr| datestring_to_date(datestr)).collect() + + rdateval.split(",").map(|datestr| datestring_to_date(datestr, tz)).collect() } @@ -441,7 +502,7 @@ mod test { #[test] fn it_works_2() { - let mut options = build_rruleset("RRULE:UNTIL=19990404T110000Z;DTSTART=19990104T110000Z;FREQ=WEEKLY;BYDAY=TU,WE"); + let mut options = build_rrule("DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR"); println!("?????????????=================?????????????"); println!("{:?}", options); println!("?????????????=== ALLL ==============?????????????"); @@ -462,13 +523,11 @@ mod test { #[test] fn it_works_4() { - let options = parse_string("RRULE:UNTIL=19990404T110000Z;DTSTART;TZID=America/New_York:19990104T110000Z;FREQ=WEEKLY;BYDAY=TU,WE"); - let parsed_opts = parse_options(&options); - println!("?????????????=================?????????????"); - println!("{:?}", options); - println!("?????????????=== PARSED ==============?????????????"); - println!("{:?}", parsed_opts); - let all = crate::rrule::RRule::new(parsed_opts).all(); + let mut set = build_rruleset("DTSTART:20120201T120000Z\nRRULE:FREQ=DAILY;COUNT=5\nEXDATE;TZID=Europe/Berlin:20120202T130000Z,20120203T130000Z"); + println!("?????????????=================??======?????????????"); + println!("{:?}", set.exdate.iter().map(|d| d.timestamp()).collect::<Vec<i64>>()); + let all = set.all(); + println!("{:?}", all.iter().map(|d| d.timestamp()).collect::<Vec<i64>>()); println!("------------------ alll ----------------"); println!("{:?}", all); } diff --git a/tests/rrule.rs b/tests/rrule.rs index fe8a814..38a76e2 100644 --- a/tests/rrule.rs +++ b/tests/rrule.rs @@ -3,7 +3,7 @@ extern crate chrono_tz; extern crate rrule; use chrono::prelude::*; -use chrono_tz::UTC; +use chrono_tz::{UTC, Tz}; use rrule::{RRule, ParsedOptions, Frequenzy}; #[cfg(test)] @@ -17,11 +17,11 @@ mod test { hour: u32, minute: u32, second: u32, - ) -> DateTime<Utc> { - Utc.ymd(year, month, day).and_hms(hour, minute, second) + ) -> DateTime<Tz> { + UTC.ymd(year, month, day).and_hms(hour, minute, second) } - fn test_recurring(options: ParsedOptions, expected_dates: &Vec<DateTime<Utc>>) { + fn test_recurring(options: ParsedOptions, expected_dates: &Vec<DateTime<Tz>>) { let mut rrule = RRule::new(options); let res = rrule.all(); |