Device Clock Handling

Get time right on devices whose clocks drift or wrap: keep two clocks, a monotonic tick since boot that drives every timeout and interval and wall-clock UTC used only for timestamps; stamp records with boot id plus monotonic time and backfill wall time once synced; compare ticks with unsigned subtraction and test by starting the counter ten seconds before the wrap; budget drift (20 ppm is about 1.7 seconds a day, an uncalibrated RC can be percent-level) and set a resync policy; sanity-check large time jumps; plan for 32-bit time_t in 2038. Use for "timestamps are 1970 after reboot", "RTC drifts a minute a week", "timeouts break after 49 days", "how do we timestamp offline data". Not for time-zone bugs in application code (debugging), a Linux host's chrony or NTP daemon (time-sync-repair), certificate lifetimes (device-trust-anchors), wake failures (sleep-wake-bug-hunt).

greenblacked Updated
The twenty-nine plugins: coding, family, gamedev, operations, delivery, security, manager, personal, career, design, llm, data, techdocs, assurance, client-apps

File contents

greenblacked/AI commit 5b0cc128ca

Frequently asked questions

npx get-skill add greenblacked/device-clock-handling