Skip to content

Commit 1831d8f

Browse files
robamuSh3Rm4n
authored andcommitted
use non-deprecated ..._opt chrono API
The functions `from_ymd` and `from_hms` were deprecated in 0.4.23 in favour of the `_opt` variants
1 parent b2cf8c8 commit 1831d8f

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/rtc.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ impl DateTimeAccess for Rtc {
179179
let hours = hours_to_u8(self.hours()?)?;
180180

181181
Ok(
182-
NaiveDate::from_ymd(year.into(), month.into(), day.into()).and_hms(
183-
hours.into(),
184-
minutes.into(),
185-
seconds.into(),
186-
),
182+
NaiveDate::from_ymd_opt(year.into(), month.into(), day.into())
183+
.unwrap()
184+
.and_hms_opt(hours.into(), minutes.into(), seconds.into())
185+
.unwrap(),
187186
)
188187
}
189188
}
@@ -333,11 +332,7 @@ impl Rtcc for Rtc {
333332
let minutes = self.minutes()?;
334333
let hours = hours_to_u8(self.hours()?)?;
335334

336-
Ok(NaiveTime::from_hms(
337-
hours.into(),
338-
minutes.into(),
339-
seconds.into(),
340-
))
335+
Ok(NaiveTime::from_hms_opt(hours.into(), minutes.into(), seconds.into()).unwrap())
341336
}
342337

343338
fn weekday(&mut self) -> Result<u8, Self::Error> {
@@ -370,7 +365,7 @@ impl Rtcc for Rtc {
370365
let month = self.month()?;
371366
let year = self.year()?;
372367

373-
Ok(NaiveDate::from_ymd(year.into(), month.into(), day.into()))
368+
Ok(NaiveDate::from_ymd_opt(year.into(), month.into(), day.into()).unwrap())
374369
}
375370
}
376371

0 commit comments

Comments
 (0)