Skip to main content

distance_of_time_in_words

Function distance_of_time_in_words 

Source
pub fn distance_of_time_in_words(from: impl Display, to: impl Display) -> String
Expand description

The time between two times, in words: 5 minutes, 2 days (Rails’ distance_of_time_in_words).

The order does not matter. See time_ago_in_words for the wording.

§Examples

use ocre::helpers::distance_of_time_in_words;

assert_eq!(distance_of_time_in_words("2026-01-01 10:00:00", "2026-01-03 09:00:00"), "2 days");