summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortim <tim@sisudata.com>2021-04-06 19:15:28 -0700
committertim <tim@sisudata.com>2021-04-06 19:15:28 -0700
commit9cf967a34f1953562eefe9329243848a0a0ac362 (patch)
tree6132d4e07e5d7e420350d38c38522e0f14706283
parent8b415c0e75de03395d907426df92dd1e9de2c399 (diff)
downloadrust_rrule-9cf967a34f1953562eefe9329243848a0a0ac362.zip
Add tests for weekly by day with non-UTC timezone
-rw-r--r--tests/rrule.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/rrule.rs b/tests/rrule.rs
index 9308360..a7b60cb 100644
--- a/tests/rrule.rs
+++ b/tests/rrule.rs
@@ -9,6 +9,8 @@ use rrule::{Frequenzy, ParsedOptions, RRule};
#[cfg(test)]
mod test {
use super::*;
+ use rrule::Options;
+ use chrono::Weekday::Sat;
fn ymd_hms(
year: i32,
@@ -6877,4 +6879,62 @@ mod test {
],
);
}
+
+ use chrono_tz::Europe::Berlin;
+ use chrono_tz::America::Los_Angeles;
+ use chrono_tz::America::New_York;
+
+ #[test]
+ fn test_timezones_weekly() {
+ let rrule_options = Options::new()
+ .dtstart(UTC.ymd(2021, 1, 1).and_hms(9, 0, 0))
+ .count(2)
+ .freq(Frequenzy::Weekly)
+ .byweekday(vec![Sat])
+ .build()
+ .unwrap();
+ let rrule = RRule::new(rrule_options.clone());
+ for o in rrule.all().iter() {
+ assert_eq!(o.weekday(), Sat);
+ }
+
+ // NYC (-5)
+ let rrule_options = Options::new()
+ .dtstart(New_York.ymd(2021, 1, 1).and_hms(9, 0, 0))
+ .count(1)
+ .freq(Frequenzy::Weekly)
+ .byweekday(vec![Sat])
+ .build()
+ .unwrap();
+ let rrule = RRule::new(rrule_options.clone());
+ for o in rrule.all().iter() {
+ assert_eq!(o.weekday(), Sat);
+ }
+
+ // How about Berlin (+1)
+ let rrule_options = Options::new()
+ .dtstart(Berlin.ymd(2021, 1, 1).and_hms(9, 0, 0))
+ .count(1)
+ .freq(Frequenzy::Weekly)
+ .byweekday(vec![Sat])
+ .build()
+ .unwrap();
+ let rrule = RRule::new(rrule_options.clone());
+ for o in rrule.all().iter() {
+ assert_eq!(o.weekday(), Sat);
+ }
+
+ // Los Angeles (-7)
+ let rrule_options = Options::new()
+ .dtstart(Los_Angeles.ymd(2021, 1, 1).and_hms(9, 0, 0))
+ .count(1)
+ .freq(Frequenzy::Weekly)
+ .byweekday(vec![Sat])
+ .build()
+ .unwrap();
+ let rrule = RRule::new(rrule_options.clone());
+ for o in rrule.all().iter() {
+ assert_eq!(o.weekday(), Sat);
+ }
+ }
}