toFuzzyDate

Converts a certain date/time to a fuzzy string.

  1. string toFuzzyDate(SysTime time)
  2. string toFuzzyDate(SysTime time, SysTime now)
  3. void toFuzzyDate(R dst, SysTime time)
  4. void toFuzzyDate(R dst, SysTime time, SysTime now)
    void
    toFuzzyDate
    (
    R
    )
    (
    ref R dst
    ,
    SysTime time
    ,
    SysTime now
    )

Parameters

time SysTime

The point in time to convert to a fuzzy string

now SysTime

Optional time value to customize the reference time, i.e. the present

dst R

Output range to write the result into

Return Value

Type: void

The non-range based overloads will return the fuzzy representation as a string

Examples

SysTime tm(string timestr) { return SysTime.fromISOExtString(timestr); }
assert(toFuzzyDate(tm("2015-11-12T19:59:59Z"), tm("2015-11-12T20:00:00Z")) == "just now");
assert(toFuzzyDate(tm("2015-11-12T19:58:55Z"), tm("2015-11-12T20:00:00Z")) == "a minute ago");
assert(toFuzzyDate(tm("2015-11-02T12:00:00Z"), tm("2015-11-12T20:00:00Z")) == "10 days ago");
assert(toFuzzyDate(tm("2014-06-06T12:00:00Z"), tm("2015-11-12T20:00:00Z")) == "a year ago");

Meta