mirror of
https://github.com/helix-editor/helix.git
synced 2024-09-11 18:58:00 +03:00
Use non-deprecated chrono Duration functions
This commit is contained in:
parent
b44b627b14
commit
6c4d986c1b
@ -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()?;
|
let date_time = NaiveDateTime::parse_from_str(date_time, format.fmt).ok()?;
|
||||||
Some(
|
Some(
|
||||||
date_time
|
date_time
|
||||||
.checked_add_signed(Duration::minutes(amount))?
|
.checked_add_signed(Duration::try_minutes(amount)?)?
|
||||||
.format(format.fmt)
|
.format(format.fmt)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
)
|
)
|
||||||
@ -35,14 +35,15 @@ pub fn increment(selected_text: &str, amount: i64) -> Option<String> {
|
|||||||
(true, false) => {
|
(true, false) => {
|
||||||
let date = NaiveDate::parse_from_str(date_time, format.fmt).ok()?;
|
let date = NaiveDate::parse_from_str(date_time, format.fmt).ok()?;
|
||||||
Some(
|
Some(
|
||||||
date.checked_add_signed(Duration::days(amount))?
|
date.checked_add_signed(Duration::try_days(amount)?)?
|
||||||
.format(format.fmt)
|
.format(format.fmt)
|
||||||
.to_string(),
|
.to_string(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
(false, true) => {
|
(false, true) => {
|
||||||
let time = NaiveTime::parse_from_str(date_time, format.fmt).ok()?;
|
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())
|
Some(adjusted_time.format(format.fmt).to_string())
|
||||||
}
|
}
|
||||||
(false, false) => None,
|
(false, false) => None,
|
||||||
|
Loading…
Reference in New Issue
Block a user