show_date_relative()

show_date_relative()#

Formats a timestamp into a human-readable relative time string, such as ‘3 days ago’ or ‘2 hours ago’.

Prototype

void show_date_relative(
    timestamp_t time,
    char *timebuf,
    int timebufsize
);

Parameters

Key

Type

Description

time

timestamp_t

The timestamp to be converted into a relative time string.

timebuf

char *

A buffer where the formatted relative time string will be stored.

timebufsize

int

The size of the buffer timebuf to ensure safe string operations.


Return Value

This function does not return a value. The formatted relative time string is stored in timebuf.

Notes

The function calculates the difference between the given timestamp and the current time, then formats it into a human-readable string. It supports various time units such as seconds, minutes, hours, days, weeks, months, and years.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples