KHTTP_EPOCH2TMS(3)
π 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β seconds0β59tm_minβ minutes0β59tm_hourβ hours0β23tm_dayβ day of month1β31tm_monβ month0β11tm_yearβ year minus1900tm_ydayβ day in year0β365tm_wdayβ day in week0β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 originalkutil_epoch2tmvals()function andKUTIL_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
- 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