Skip to main content

rtc_fields_plausible

Function rtc_fields_plausible 

Source
pub(super) fn rtc_fields_plausible(dt: &RtcDateTime) -> bool
Expand description

Returns true when every field of a CMOS read is in range.

A CMOS that was never programmed - or a platform whose port I/O is a stub, which is what arch::io::{inb,outb} are on riscv64 - reads back as zeroes or 0xFF. RtcDateTime::to_timestamp accepts both without complaint and returns an instant that looks believable, so the fields have to be checked before the wall clock is believed. Month 0 or 255 is the giveaway.