KHTTP_EPOCH2TMS(3) Library Functions Manual KHTTP_EPOCH2TMS(3)
NAME
KHTTP_EPOCH2TM, khttp_epoch2tms — convert time to components
LIBRARY
library “libkcgi”
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
Format an epoch value (seconds since Jan 1, 1970, 00:00:00 UTC) into its broken-down time components suitable for struct tm operations.
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.
The KHTTP_EPOCH2TM() macro fills in tm with the above values. Other fields in the struct tm structure, like tm_gmtoff, are not touched.
These deprecate the original kutil_epoch2tmvals() function and KUTIL_EPOCH2TM() macro, both of which had undefined behaviour in some corner cases.
For conversion without possible overflow or underflow, use khttp_epoch2datetime(3).
RETURN VALUES
These return zero on failure and non-zero on success. Failure occurs if epoch will overflow or underflow tm_year, which occurs around the year ±6.7+16.
SEE ALSO
khttp_datetime2epoch(3), khttp_epoch2datetime(3), khttp_epoch2str(3)
AUTHORS
Written by Kristaps Dzonsons <[email protected]>. GNU $Mdocdate$ KHTTP_EPOCH2TMS(3)