fmt_httpdate(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– fmt_httpdate β€” the group chat's favorite date printer πŸ’–

okay so real talk, this page lives in the Library Functions Manual, section 3, and its whole name is fmt_httpdate(3). she's a library function, she's iconic, and she has exactly one job: turning a time_t into the exact ASCII date format that HTTP is obsessed with. no cap. πŸŽ€


✨ NAME ✨

fmt_httpdate β€” write a date in ASCII as in the HTTP protocol πŸ¦‹


🌸 SYNTAX 🌸

#include <libowfat/fmt.h>

size_t fmt_httpdate(char *dest,time_t source);

bestie look at that signature, it's giving "two arguments, zero drama" πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

so fmt_httpdate writes a date in the ASCII representation that the HTTP protocol defines, and it looks exactly like this:

Sun, 06 Nov 1994 08:49:37 GMT

that's the vibe. that's the format. that string is literally the whole personality of this function. ⭐

heads up: fmt_httpdate does not append \0. she does not terminate your string for you. the null byte is your problem, not hers. 😭

and here's the cute little trick she does 🧚 β€” if dest equals FMT_LEN (i.e. is zero), then fmt_httpdate returns the number of bytes it would have written. so you can literally ask her "how much room do I need, queen?" before committing to anything. no guessing. we love a function that respects your buffer. 🫢

also: the output of fmt_httpdate is 29 until Jan 1st 10000. twenty-nine bytes of pure date realness, and she's holding that length for a very long time. πŸ‘‘


okay that's the whole page, mwah πŸ’œ

this lil sign-off is brought to you by the footer, which honestly just says fmt_httpdate(3) again β€” section 3, Library Functions Manual, no extra version or date tea to spill. she said "my name is enough." and honestly? she's right. periodt. πŸ’–βœ¨