Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
matrix:
target:
- { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu }
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
- { name: macOS, os: macos-latest, triple: aarch64-apple-darwin }
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
version:
- 1.81.0 # MSRV
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ test:
@cargo test --all-features --all-targets

check:
@cargo +nightly fmt --all
@cargo fmt --all
@cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features
@cargo update --dry-run
@cargo outdated -wR
@cargo machete
@cargo doc --no-deps --all-features --examples --document-private-items
@cargo +nightly udeps --all-targets --all-features
@cargo udeps --all-targets --all-features

check_nightly:
@cargo +nightly fmt --all
@cargo +nightly clippy --fix --allow-dirty --allow-staged --all-targets --all-features
@cargo +nightly udeps --all-targets --all-features

check_strictly:
@cargo +nightly clippy --fix --allow-dirty --allow-staged --all-features --all-targets -- -W clippy::all -W clippy::pedantic -W clippy::cargo
Expand Down
1 change: 1 addition & 0 deletions rrule-afl-fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rust-version.workspace = true
[dependencies]
afl = "*"
chrono = "0.4.39"
chrono-tz = "0.10.1"
num-traits = "0.2.19"

[dependencies.rrule]
Expand Down
5 changes: 3 additions & 2 deletions rrule-afl-fuzz/src/take_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ pub fn take_datetime(input: &mut &[u8]) -> DateTime<Tz> {
LocalResult::None => {
// Will always succeed
let nanos: i64 = take_data_i64(input);
Utc.timestamp_nanos(nanos).with_timezone(&Tz::UTC)
Utc.timestamp_nanos(nanos)
.with_timezone(&Tz::from_static(chrono_tz::UTC))
}
LocalResult::Single(datetime) | LocalResult::Ambiguous(datetime, _) => {
datetime.with_timezone(&Tz::UTC)
datetime.with_timezone(&Tz::from_static(chrono_tz::UTC))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions rrule-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rust-version.workspace = true
[dependencies]
rrule = { path = "../rrule" }
chrono = "0.4.39"
chrono-tz = "0.10.1"
clap = { version = "4.5.26", features = ["derive"] }
rrule-afl-fuzz = { version = "0.1.0", path = "../rrule-afl-fuzz" }
log = "0.4.25"
Expand Down
2 changes: 1 addition & 1 deletion rrule-debugger/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_parsed_rrule() {
}

fn ymd_hms(year: i32, month: u32, day: u32, hour: u32, minute: u32, second: u32) -> DateTime<Tz> {
Tz::UTC
Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(year, month, day, hour, minute, second)
.unwrap()
}
4 changes: 3 additions & 1 deletion rrule/examples/manual_rrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use rrule::{Frequency, RRule, Tz};

fn main() {
// Build an RRuleSet that starts the first day in 2020 at 9:00AM and occurs daily 5 times
let start_date = Tz::UTC.with_ymd_and_hms(2020, 1, 1, 9, 0, 0).unwrap();
let start_date = Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(2020, 1, 1, 9, 0, 0)
.unwrap();
let rrule_set = RRule::default()
.count(5)
.freq(Frequency::Daily)
Expand Down
12 changes: 10 additions & 2 deletions rrule/examples/manual_rrule_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@ fn main() {
NWeekday::Every(Weekday::Tue),
NWeekday::Every(Weekday::Wed),
])
.build(Tz::UTC.with_ymd_and_hms(2020, 1, 1, 9, 0, 0).unwrap())
.build(
Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(2020, 1, 1, 9, 0, 0)
.unwrap(),
)
.expect("RRule invalid");

// Build exrule that occurs weekly on Wednesday
let exrule = RRule::default()
.count(4)
.freq(Frequency::Weekly)
.by_weekday(vec![NWeekday::Every(Weekday::Wed)])
.validate(Tz::UTC.with_ymd_and_hms(2020, 1, 1, 9, 0, 0).unwrap())
.validate(
Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(2020, 1, 1, 9, 0, 0)
.unwrap(),
)
.expect("RRule invalid");

let recurrences = rrule_set.exrule(exrule).all(10).dates;
Expand Down
6 changes: 4 additions & 2 deletions rrule/examples/timezone_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ use chrono::{DateTime, TimeZone};
use rrule::{Frequency, RRule, Tz};

fn main() {
let tz = Tz::Europe__Berlin;
let tz = Tz::from(chrono_tz::Europe::Berlin);
let start_date = tz.with_ymd_and_hms(2020, 1, 1, 9, 0, 0).unwrap();
let exdate = Tz::UTC.with_ymd_and_hms(2020, 1, 2, 8, 0, 0).unwrap();
let exdate = Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(2020, 1, 2, 8, 0, 0)
.unwrap();

// Build an rrule set that occurs daily at 9:00 for 4 times
let rrule_set = RRule::default()
Expand Down
2 changes: 1 addition & 1 deletion rrule/src/core/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ pub(crate) fn datetime_to_ical_format(dt: &chrono::DateTime<Tz>) -> String {
}

let dt = dt.format("%Y%m%dT%H%M%S");
format!("{}:{}{}", tz_prefix, dt, tz_postfix)
format!("{tz_prefix}:{dt}{tz_postfix}")
}
9 changes: 5 additions & 4 deletions rrule/src/core/rrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Display for Frequency {
Self::Minutely => "MINUTELY",
Self::Secondly => "SECONDLY",
};
write!(f, "{}", name)
write!(f, "{name}")
}
}

Expand Down Expand Up @@ -188,13 +188,13 @@ impl Display for NWeekday {
Self::Nth(number, wd) => {
let mut wd_str = weekday_to_str(*wd);
if *number != 1 {
wd_str = format!("{}{}", number, wd_str);
wd_str = format!("{number}{wd_str}");
};
wd_str
}
};

write!(f, "{}", weekday)
write!(f, "{weekday}")
}
}

Expand Down Expand Up @@ -368,6 +368,7 @@ impl RRule<Unvalidated> {
self.by_month = by_month
.iter()
.map(|month| {
#[allow(clippy::missing_panics_doc)] // Cannot actually panic.
u8::try_from(month.number_from_month()).expect("1-12 is within range of u8")
})
.collect();
Expand Down Expand Up @@ -647,7 +648,7 @@ impl<S> Display for RRule<S> {
}

if let Some(count) = &self.count {
res.push(format!("COUNT={}", count));
res.push(format!("COUNT={count}"));
}

// One interval is the default, no need to expose it.
Expand Down
16 changes: 12 additions & 4 deletions rrule/src/core/rruleset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ mod tests {
let rruleset = RRuleSet::from_str(rruleset_str).unwrap();

// Check start date
let dt_start = Tz::UTC.with_ymd_and_hms(2012, 2, 1, 9, 30, 0).unwrap();
let dt_start = Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(2012, 2, 1, 9, 30, 0)
.unwrap();
assert_eq!(rruleset.dt_start, dt_start);

// Check rrule
Expand All @@ -371,8 +373,12 @@ mod tests {
assert_eq!(
rruleset.rdate,
vec![
Tz::UTC.with_ymd_and_hms(1997, 1, 1, 0, 0, 0).unwrap(),
Tz::UTC.with_ymd_and_hms(1997, 1, 20, 0, 0, 0).unwrap()
Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(1997, 1, 1, 0, 0, 0)
.unwrap(),
Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(1997, 1, 20, 0, 0, 0)
.unwrap()
]
);

Expand All @@ -389,7 +395,9 @@ mod tests {
// Check exdate
assert_eq!(
rruleset.exdate,
vec![Tz::UTC.with_ymd_and_hms(1997, 1, 21, 0, 0, 0).unwrap()]
vec![Tz::from(chrono_tz::UTC)
.with_ymd_and_hms(1997, 1, 21, 0, 0, 0)
.unwrap()]
);

// Serialize to string again
Expand Down
Loading
Loading