KHTTP_EPOCH2STR(3)
okay bestie, welcome to the KHTTP_EPOCH2STR(3) page β it lives in the Library Functions Manual, and it's literally about turning epoch time into a string. π°οΈβ¨
π NAME π
khttp_epoch2str, khttp_epoch2ustr β convert time to a string π
π LIBRARY π
library βlibkcgiβ β yes, that's the one, bestie.
β¨ SYNOPSIS β¨
#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);
π¦ DESCRIPTION π¦
okay so here's the vibe: these functions format an epoch value (seconds since Jan 1, 1970, 00:00:00 UTC) into the buffer buf of size sz, and sz should be greater than or equal to 64 bytes. π
If there isn't enough space for the formatted date, the buffer is truncated to the available size. It is always NUL-terminated β always, no cap. π«Ά
The output of khttp_epoch2str() conforms to RFC 5322 (βWed, 02 Oct 2002 13:00:00 GMTβ). ποΈ But heads up: 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. Not me causing chaos, it's just in the docs. π
khttp_epoch2ustr() 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 kutil_epoch2str() and kutil_epoch2utcstr() functions, which had undefined behaviour in some corner cases. π So yeah, use the new ones, bestie.
π RETURN VALUES π
Returns a pointer to the input buf or NULL if buf is NULL, sz is zero, or time conversion fails. That's the whole check, periodt. π
π§ SEE ALSO π§
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>. π Iconic behaviour, honestly.
cute sign-off: this page came from Debian, with the $Mdocdate$ date stamp, and it's the KHTTP_EPOCH2STR(3) page. mwah πβ¨
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- Copyright (c) 2016--2017, 2020 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms