use core::num::TryFromIntError;
use chrono::{DateTime, TimeZone as _, Utc};
use crate::Rtc;
impl Rtc {
pub fn get_time(&self) -> DateTime<Utc> {
Utc.timestamp_opt(self.get_unix_timestamp().into(), 0)
.unwrap()
}
pub fn set_time(&mut self, time: DateTime<Utc>) -> Result<(), TryFromIntError> {
self.set_unix_timestamp(time.timestamp().try_into()?);
Ok(())
}
pub fn set_match(&mut self, match_time: DateTime<Utc>) -> Result<(), TryFromIntError> {
self.set_match_timestamp(match_time.timestamp().try_into()?);
Ok(())
}
}