Skip to content

Commit

Permalink
Capitalize FREQ value in string representation
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeringdal committed Nov 22, 2023
1 parent 8da601c commit 0647a69
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
version:
- 1.64.0 # MSRV
- 1.70.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.12.0 (2023-xx-xx)

- Fix to ensure freq is capitalized in the string representation
- MSRV is bumped to `v1.70.0` from `v1.64.0`

## 0.11.0 (2023-07-18)

### Changed
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[workspace.package]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.64.0"
rust-version = "1.70.0"

[workspace]
members = [
"rrule",
"rrule-debugger",
]
resolver = "2"

# These are the 2 packages to mainly work on.
# So `cargo test` and `cargo run` both work.
Expand Down
16 changes: 8 additions & 8 deletions rrule/src/core/rrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ pub enum Frequency {
impl Display for Frequency {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let name = match self {
Self::Yearly => "yearly",
Self::Monthly => "monthly",
Self::Weekly => "weekly",
Self::Daily => "daily",
Self::Hourly => "hourly",
Self::Minutely => "minutely",
Self::Secondly => "secondly",
Self::Yearly => "YEARLY",
Self::Monthly => "MONTHLY",
Self::Weekly => "WEEKLY",
Self::Daily => "DAILY",
Self::Hourly => "HOURLY",
Self::Minutely => "MINUTELY",
Self::Secondly => "SECONDLY",
};
write!(f, "{}", name)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ fn n_weekday_cmp(val1: NWeekday, val2: NWeekday) -> Ordering {

impl PartialOrd for NWeekday {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(n_weekday_cmp(*self, *other))
Some(self.cmp(other))
}
}

Expand Down
17 changes: 16 additions & 1 deletion rrule/src/tests/regression.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use chrono::Month;

use crate::tests::common;
use crate::RRuleSet;
use crate::{Frequency, RRule, RRuleSet};

#[test]
fn issue_34() {
Expand Down Expand Up @@ -45,3 +47,16 @@ fn issue_61() {
let res = rrule_set.all(10).dates;
assert_eq!(res.len(), 10);
}

// Frequency should be capitalized
#[test]
fn issue_97() {
let rrule = RRule::new(Frequency::Yearly)
.by_month_day((24..=26).collect())
.by_month(&[Month::December]);

assert_eq!(
rrule.to_string(),
"FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=24,25,26"
);
}

0 comments on commit 0647a69

Please sign in to comment.