Crate timeago [] [src]

Given a Duration, lossily format it like in 'N days ago'. Parsing it back to Duration is not supported yet (See chrono-english crate). Multiple languages are supported though Language trait. Enable isolang feature to gain support of getting Language impl from lsolang::Language. You can configure minimum and maximum time units, as well as "precision" of how many items to emit. Fractional results like "1.5 days ago" are not supported. There is a special simplified version to get compact 5-character representation: format_5chars. Main struct is Formatter.

Re-exports

pub use languages::from_isolang;
pub use languages::english::English;

Modules

languages

Natural languages supported out-of-the-box for the formatting. You can implement a language yourself by deriving the Language trait. You can also choose the language at runtime using the isolang cargo feature. Note: Currently translations expect of English and Russian are not authoritative.

Structs

Formatter

Main formatter struct. Build it with new() and maybe modify some options, then use convert.

Enums

Style [
Deprecated
]

Simple formatting style for deprecated format.

TimeUnit

Various units of time to specify as maximum or minimum. Note that calculations are approximate, not calendar-based.

Traits

Language

Interface for connecting natural languages to use for the formatting See "language" module documentation for details.

Functions

format [
Deprecated
]

Do the formatting. See Style's docstring for formatting options. If you need just simple mode without bloated featureful implementation, use version 0.0.2 of this crate

format_5chars

A simplified formatter, resulting in short strings like "02Yea" or " now " or "07min". Designed to always give 5-character strings.