Skip to content

Commit

Permalink
cargo-crev: replace deprecated days with try_days
Browse files Browse the repository at this point in the history
The "days" function on "chrono::Duration" is deprecated in favor of
"try_days". Replace it with "try_days" and add an assertion that 2 days
doesn't overflow chrono's "TimeDelta".

Signed-off-by: Thomas Böhler <[email protected]>
  • Loading branch information
Witcher01 authored and kornelski committed May 19, 2024
1 parent 965f790 commit 71cae66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cargo-crev/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ pub fn crate_review_activity_check(
}
}

if activity.timestamp + chrono::Duration::days(2) < crev_common::now() {
if activity.timestamp
+ chrono::Duration::try_days(2).expect("2 days doesn't overflow TimeDelta")
< crev_common::now()
{
return Err(ActivityCheckError::Expired);
}
} else {
Expand Down

0 comments on commit 71cae66

Please sign in to comment.