Skip to main content

Module helpers

Module helpers 

Source
Expand description

Small pure helpers shared by views and handlers.

Functions§

compact_count
A count short enough to sit beside an icon: 999, 1.2k, 15k, 3.4M. Rounded down, so it never says more than there is.
readable_size
bytes as a size someone reads: in the unit that leaves one to three digits before the point, with one after it past the first unit.
relative_time
How long ago then was, seen from now, as a feed shows it: now, 5m, 3h, 2d, 6w, 1y. A time in the future (a clock that runs ahead) reads as now.
truncate_chars
At most max characters of text, with an ellipsis when it was longer.
unix_now
Seconds since the Unix epoch, now.