Expand description
Wall-clock units and formats, each defined once: a day, the civil calendar, how long ago.
The calendar is borg-trace’s (it parses transcript stamps with it), re-exported here so that every crate on top of borg reaches the one routine. The web page (borg-web ui, its own wasm workspace) has its own copy in ui/src/util.rs.
Constants§
- DAY_MS
- A day in milliseconds. Derived: 24 h of 60 min of 60 s of 1000 ms, a unit, not a choice. Every “a day” or “a week” in borg is a multiple of it.
Functions§
- ago
- How long ago something was, from its age in ms, in at most 6 characters for an age under 100
days:
45s,12m,3h05munder a day,2dfrom a day on. A negative age (a sender’s clock ahead of this one) is0s. - civil_
from_ days - The civil date
(year, month, day)of a day number since 1970-01-01, Howard Hinnant’scivil_from_days: the inverse ofdays_from_civil, with the same calendar numbers. - days_
from_ civil - Days since 1970-01-01 of the civil (proleptic Gregorian) date
y-m-d, Howard Hinnant’sdays_from_civil. The one calendar routine of borg’s crates, withcivil_from_days(borg’s clock.rs re-exports both). Its numbers are the calendar’s (method): 146 097 days in a 400-year era, 719 468 days from 0000-03-01 to 1970-01-01, the year counted from March.