Skip to content

Commit

Permalink
fix: render weekdays as valid rrule strings
Browse files Browse the repository at this point in the history
Previously, weekdays would've been rendered by their built-in name.
  • Loading branch information
tomquist committed May 3, 2024
1 parent ec5a9b9 commit 20b06ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rrule/src/core/rrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl<S> Display for RRule<S> {

// 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() {
Expand Down
12 changes: 11 additions & 1 deletion rrule/src/tests/regression.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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::<RRule<Unvalidated>>();

// Convert to string...
let rrule_str = format!("{}", rrule.unwrap());
assert!(rrule_str.contains("WKST=SU"));
}

0 comments on commit 20b06ed

Please sign in to comment.