KHTTP_DATETIME2EPOCH(3)

NAME
khttp_date2epoch, khttp_datetime2epoch - validate and convert date and time

LIBRARY
libkcgi

SYNOPSIS
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
int
khttp_date2epoch(int64_t *res, int64_t day, int64_t mon, int64_t year, int64_t hour, int64_t min, int64_t sec);
int
khttp_datetime2epoch(int64_t *res, int64_t day, int64_t mon, int64_t year, int64_t hour, int64_t min, int64_t sec);

DESCRIPTION
Convert broken-day date and time values into seconds since 00:00:00 UTC, 1970-01-01. The date and time values are accepted as UTC. khttp_date2epoch() is equivalent to khttp_datetime2epoch() but with zero hour, min, and sec arguments. If res is NULL, simply check the time values for correctness.

Date correctness means that input values fall within the following acceptable ranges:
sec | seconds 0–59
min | minutes 0–59
hour | hours 0–23
day | day of month 1–31
mon | month 1–12
year | year -2.9e11–2.9e11

The year bound is the maximum year value that may be converted to seconds for a 64-bit integer.

These deprecate kutil_date2epoch(), kutil_date_check(), kutil_datetime2epoch(), and kutil_datetime_check(), which should no longer be used.

RETURN VALUES
Return zero if the given values do not correspond to a valid date and time, non-zero otherwise.

SEE ALSO
khttp_epoch2datetime(3), khttp_epoch2str(3), khttp_epoch2tms(3)

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