summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Meringdal <fredrikmeringdal@Fredriks-MacBook-Pro.local>2021-04-07 11:47:03 +0200
committerFredrik Meringdal <fredrikmeringdal@Fredriks-MacBook-Pro.local>2021-04-07 11:47:03 +0200
commit9392f9836d41c691b5049a095b95ff12f876f758 (patch)
treefa65e5e73032a1eb55b868c2d99da90135e9ec55
parenta4ce2bedf7da9d40a8af524c41e9ea8332f966b2 (diff)
downloadrust_rrule-9392f9836d41c691b5049a095b95ff12f876f758.zip
Fix #14
-rw-r--r--src/rrulestr.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/rrulestr.rs b/src/rrulestr.rs
index a2544c6..c2c197f 100644
--- a/src/rrulestr.rs
+++ b/src/rrulestr.rs
@@ -563,10 +563,11 @@ pub fn build_rrule(s: &str) -> Result<RRule, RRuleParseError> {
..
} = parse_input(&s)?;
- rrule_vals[0].tzid = tzid;
- rrule_vals[0].dtstart = dtstart;
-
- let parsed_opts = parse_options(&rrule_vals[0])?;
+ // TODO: find out why rrule_vals can be more than one
+ let mut rrule_opts = rrule_vals.remove(rrule_vals.len() - 1);
+ rrule_opts.tzid = tzid;
+ rrule_opts.dtstart = dtstart;
+ let parsed_opts = parse_options(&rrule_opts)?;
Ok(RRule::new(parsed_opts))
}
@@ -787,4 +788,15 @@ mod test {
assert_eq!(3, dates[dates.len() - 1].month());
assert_eq!(2021, dates[dates.len() - 1].year());
}
+
+ #[test]
+ fn test_zulu() {
+ // let rrule_str = "DTSTART;20210405T150000Z\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO";
+ let rrule_str = "DTSTART:20210405T150000Z\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO";
+ let rrule: RRule = rrule_str.parse().unwrap();
+ assert_eq!(rrule.options.freq, Frequenzy::Weekly);
+ assert_eq!(rrule.options.byweekday, vec![0]);
+ assert_eq!(rrule.options.interval, 1);
+ assert_eq!(rrule.options.dtstart, UTC.ymd(2021, 4, 5).and_hms(15, 0, 0));
+ }
}