From 20b06eda3998eac7632fb5b2ef549e613125fad0 Mon Sep 17 00:00:00 2001 From: Tom Quist Date: Fri, 3 May 2024 22:00:31 +0200 Subject: [PATCH 1/2] fix: render weekdays as valid rrule strings Previously, weekdays would've been rendered by their built-in name. --- rrule/src/core/rrule.rs | 2 +- rrule/src/tests/regression.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rrule/src/core/rrule.rs b/rrule/src/core/rrule.rs index b3fadde..3ea9838 100644 --- a/rrule/src/core/rrule.rs +++ b/rrule/src/core/rrule.rs @@ -656,7 +656,7 @@ impl Display for RRule { // Monday is the default, no need to expose it. if self.week_start != Weekday::Mon { - res.push(format!("WKST={}", &self.week_start)); + res.push(format!("WKST={}", weekday_to_str(self.week_start))); } if !self.by_set_pos.is_empty() { diff --git a/rrule/src/tests/regression.rs b/rrule/src/tests/regression.rs index debfbc2..1342045 100644 --- a/rrule/src/tests/regression.rs +++ b/rrule/src/tests/regression.rs @@ -1,7 +1,7 @@ use chrono::Month; use crate::tests::common; -use crate::{Frequency, RRule, RRuleSet}; +use crate::{Frequency, RRule, RRuleSet, Unvalidated}; #[test] fn issue_34() { @@ -60,3 +60,13 @@ fn issue_97() { "FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=24,25,26" ); } + +#[test] +fn issue_111() { + let rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;WKST=SU" + .parse::>(); + + // Convert to string... + let rrule_str = format!("{}", rrule.unwrap()); + assert!(rrule_str.contains("WKST=SU")); +} \ No newline at end of file From 95e7256cbcc6793f80dd4f180b6ab40239b3cf1f Mon Sep 17 00:00:00 2001 From: Tom Quist Date: Sun, 19 May 2024 15:44:24 +0200 Subject: [PATCH 2/2] fix lint errors --- rrule/src/tests/regression.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rrule/src/tests/regression.rs b/rrule/src/tests/regression.rs index 1342045..3e5195d 100644 --- a/rrule/src/tests/regression.rs +++ b/rrule/src/tests/regression.rs @@ -63,10 +63,9 @@ fn issue_97() { #[test] fn issue_111() { - let rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;WKST=SU" - .parse::>(); + let rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;WKST=SU".parse::>(); - // Convert to string... + // Convert to string... let rrule_str = format!("{}", rrule.unwrap()); assert!(rrule_str.contains("WKST=SU")); -} \ No newline at end of file +}