diff options
author | Michael Davis | 2024-03-12 13:58:33 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2024-03-14 05:13:56 +0000 |
commit | 6c4d986c1b1ac4e350dced513b6608ba4464cde3 (patch) | |
tree | 2131f2ec2a62e14baadef342eb1cea5297bd515c /helix-core/src/increment/date_time.rs | |
parent | b44b627b1403f8a3e23251bc79558d482346c4b0 (diff) |
Use non-deprecated chrono Duration functions
Diffstat (limited to 'helix-core/src/increment/date_time.rs')
-rw-r--r-- | helix-core/src/increment/date_time.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-core/src/increment/date_time.rs b/helix-core/src/increment/date_time.rs index 2980bb58..04cff6b4 100644 --- a/helix-core/src/increment/date_time.rs +++ b/helix-core/src/increment/date_time.rs @@ -27,7 +27,7 @@ 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(), ) @@ -35,14 +35,15 @@ pub fn increment(selected_text: &str, amount: i64) -> Option<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, |