KHTTP_EPOCH2STR(3) Library Functions Manual KHTTP_EPOCH2STR(3)

khttp_epoch2str, khttp_epoch2ustrconvert time to a string

library “libkcgi”

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

char *
khttp_epoch2str(int64_t epoch, char *buf, size_t sz);

char *
khttp_epoch2ustr(int64_t epoch, char *buf, size_t sz);

Format an epoch value (seconds since Jan 1, 1970, 00:00:00 UTC) into the buffer buf of size sz, which should be greater than or equal to 64 bytes. If not enough space is given for the formatted date, the buffer is truncated to the available size. It is always NUL-terminated.

The output of () conforms to RFC 5322 (“Wed, 02 Oct 2002 13:00:00 GMT”). However, the year may be greater than four digits or less than 1900, or even be negative, which is contrary to RFC 5322 section 3.3.

() conforms to ISO 8601 (“2002-10-02T13:00:00Z”), again with the stipulation that the year may be greater than 4 digits or be less than zero.

These deprecate the original () and () functions, which had undefined behaviour in some corner cases.

Returns a pointer to the input buf or NULL if buf is NULL, sz is zero, or time conversion fails.

khttp_datetime2epoch(3), khttp_epoch2datetime(3), khttp_epoch2tms(3)

Written by Kristaps Dzonsons <>.

September 23, 2021 OpenBSD 6.7