KHTTP_EPOCH2STR(3)

πŸ“¦ version 1.0.1, in alpine 3.24

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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms