Trait rtcc::DateTimeAccess

source ·
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:

  1. The time is 01:59:59
  2. A call to hours() returns 1.
  3. The time is increased to 02:00:00.
  4. A call to minutes() returns 0.
  5. A call to seconds() returns 0.
  6. 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§

source

type Error

Error type

Required Methods§

source

fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>

Read the date and time.

source

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.

Implementors§