Skip to main content

Module clock

Module clock 

Source
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, 3h05m under a day, 2d from a day on. A negative age (a sender’s clock ahead of this one) is 0s.
civil_from_days
The civil date (year, month, day) of a day number since 1970-01-01, Howard Hinnant’s civil_from_days: the inverse of days_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’s days_from_civil. The one calendar routine of borg’s crates, with civil_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.