pub fn time_ago_in_words(value: impl Display) -> StringExpand description
The time from value to now, in words: about 3 hours (Rails’ time_ago_in_words).
Add “ago” yourself: {{ post.created_at|time_ago_in_words }} ago. The
wording is Rails’: less than a minute, 1 minute, N minutes,
about 1 hour, about N hours, 1 day, N days, about 1 month,
about 2 months, N months, then about N years, over N years and
almost N years.
§Examples
let three_hours_ago = ocre::now() - 3 * 3600;
assert_eq!(ocre::helpers::time_ago_in_words(three_hours_ago), "about 3 hours");