Skip to content

Commit

Permalink
Use non-deprecated chrono Duration functions
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis authored and archseer committed Mar 14, 2024
1 parent b44b627 commit 6c4d986
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions helix-core/src/increment/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,23 @@ pub fn increment(selected_text: &str, amount: i64) -> Option<String> {
let date_time = NaiveDateTime::parse_from_str(date_time, format.fmt).ok()?;
Some(
date_time
.checked_add_signed(Duration::minutes(amount))?
.checked_add_signed(Duration::try_minutes(amount)?)?
.format(format.fmt)
.to_string(),
)
}
(true, false) => {
let date = NaiveDate::parse_from_str(date_time, format.fmt).ok()?;
Some(
date.checked_add_signed(Duration::days(amount))?
date.checked_add_signed(Duration::try_days(amount)?)?
.format(format.fmt)
.to_string(),
)
}
(false, true) => {
let time = NaiveTime::parse_from_str(date_time, format.fmt).ok()?;
let (adjusted_time, _) = time.overflowing_add_signed(Duration::minutes(amount));
let (adjusted_time, _) =
time.overflowing_add_signed(Duration::try_minutes(amount)?);
Some(adjusted_time.format(format.fmt).to_string())
}
(false, false) => None,
Expand Down

0 comments on commit 6c4d986

Please sign in to comment.