Expand description
Conversion between broken-down civil time and the Unix epoch.
Receivers report the date and time of day as separate fields, and
PROP_TIME carries one UINT32 second count, so something has to
convert between them. Hosts need the same conversion in reverse to
show an operator what the device thinks the time is.
The arithmetic is Howard Hinnant’s days-from-civil algorithm: integer only, no lookup tables, and correct for the whole proleptic Gregorian calendar rather than only for the years a leap-year table happens to cover.
Everything here is UTC. A local time-zone offset is presentation,
applied by whatever is doing the presenting — see
DateTime::shifted.
Structs§
- Date
Time - A broken-down civil date and time, in UTC unless a caller has deliberately shifted it.
Constants§
- MAX_
EPOCH - The largest second count
u32can express: 2106-02-07T06:28:15Z. - MIN_
PLAUSIBLE_ EPOCH - The earliest instant a receiver is believed: 2020-01-01T00:00:00Z.
Functions§
- civil_
from_ days - The proleptic Gregorian date
daysafter 1970-01-01. The inverse ofdays_from_civil. - days_
from_ civil - Days since 1970-01-01 for a proleptic Gregorian date.
- days_
in_ month - Days in
monthofyear, 1-indexed. Zero for an out-of-range month, which makes an invalid month fail the day check inDateTime::is_validrather than needing its own branch. - is_
leap_ year - The proleptic Gregorian leap-year rule.