KHTTP_EPOCH2TMS(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸŽ€ NAME πŸŽ€

KHTTP_EPOCH2TM, khttp_epoch2tms β€” convert time to components

okay so bestie, this is the KHTTP_EPOCH2TMS(3) page from the Library Functions Manual, and it is literally about converting time to components. main character energy for calendar math, no cap.

πŸ“š LIBRARY πŸ“š

library β€œlibkcgi” β€” that's the squad this one runs with. 🫢

✨ SYNOPSIS ✨

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

int
khttp_epoch2tms(int64_t epoch, int *tm_sec, int *tm_min, int *tm_hour,
    int *tm_mday, int *tm_mon, int *tm_year, int *tm_wday,
    int *tm_yday);

int
KHTTP_EPOCH2TM(int64_t epoch, struct tm *tm);

πŸ’– DESCRIPTION πŸ’–

the whole plot: format an epoch value (seconds since Jan 1, 1970, 00:00:00 UTC) into its broken-down time components suitable for struct tm operations. it's giving β€œcalendar dissection, but make it cute,” and honestly? iconic, fr fr.

not me being highkey obsessed with all the components, but look β€” the components of khttp_epoch2tms() are filled in as follows:

  • tm_sec β€” seconds 0–59
  • tm_min β€” minutes 0–59
  • tm_hour β€” hours 0–23
  • tm_day β€” day of month 1–31
  • tm_mon β€” month 0–11
  • tm_year β€” year minus 1900
  • tm_yday β€” day in year 0–365
  • tm_wday β€” day in week 0–6 (Sunday = 0)

If any of the pointers are NULL, they are ignored. lowkey convenient.

The KHTTP_EPOCH2TM() macro fills in tm with the above values. Other fields in the struct tm structure, like tm_gmtoff, are not touched. periodt.

heads up: these deprecate the original kutil_epoch2tmvals() function and KUTIL_EPOCH2TM() macro, both of which had undefined behaviour in some corner cases. so yeah, the old ones had a messy vibe in some corner cases.

For conversion without possible overflow or underflow, use khttp_epoch2datetime(3). that's the safe bestie move.

πŸŽ€ RETURN VALUES πŸŽ€

These return zero on failure and non-zero on success. yep, zero is the failure vibe here β€” don't get it twisted.

Failure occurs if epoch will overflow or underflow tm_year, which occurs around the year ±6.7+16. 😭

πŸ‘€ SEE ALSO πŸ‘€

go peek at these, iykyk:

🫢 AUTHORS 🫢

Written by Kristaps Dzonsons <kristaps@bsd.lv>. slay.


xoxo, your Debian bestie πŸ’– β€” page version/date $Mdocdate$, manual KHTTP_EPOCH2TMS(3) 🫢

πŸ“¦ 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