pub trait DateTimeAccess {
type Error;
// Required methods
fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>;
fn set_datetime(
&mut self,
datetime: &NaiveDateTime,
) -> Result<(), Self::Error>;
}
Expand description
Real-Time Clock / Calendar DateTimeAccess trait to read/write a complete date/time.
Prefer to use only these methods rather than the individual methods from the
Rtcc
trait to avoid situations where the passing of time makes the results
of the method calls inconsistent if you combine the results of several methods.
For example, this can happen at certain timepoints:
- The time is
01:59:59
- A call to
hours()
returns 1. - The time is increased to
02:00:00
. - A call to
minutes()
returns 0. - A call to
seconds()
returns 0. - Your system thinks it is
01:00:00
.
The same applies to the date as well, as well as when calling setter methods.
Required Associated Types§
Required Methods§
Sourcefn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>
fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>
Read the date and time.
Sourcefn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error>
fn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error>
Set the date and time.
This will set the hour operating mode to 24h and the weekday to the day number starting from Sunday = 1.