pub fn clock_source(ctx: &ServiceContext) -> ClockSourceExpand description
Where the wall clock came from, so a displayed timestamp can say what it stands on.
This is the check datetime tells you to make, and it is the difference between a date and a
date you can quote. The four answers are genuinely different claims:
ClockSource::Unset | No clock at all. Whatever datetime renders is not today. |
ClockSource::Rtc | A local hardware clock reading a plausible date. |
ClockSource::Ntp | Corrected from the network this boot. |
ClockSource::Floor | A LOWER BOUND carried from the last boot - real, advancing correctly, but blind to how long the machine was off. |
Floor is the one worth reading twice, and it is why this is an enum rather than a bool. Several
of the boards this runs on have no RTC, so the clock starts from a persisted floor and creeps
forward correctly while being arbitrarily far behind. Reporting that as Rtc would claim hardware
the board does not have; reporting it as Unset would deny a time it is displaying.
A machine that cannot be asked reads ClockSource::Unset, deliberately. The time service
is restartable, so an unanswered question is normal during a restart - and an unknown clock and an
unset clock oblige a caller to do the same thing, which is not to quote the date as fact.