mirror of
https://github.com/bdnugget/kcgi.git
synced 2026-11-07 05:47:27 +00:00
108 lines
2.7 KiB
Plaintext
108 lines
2.7 KiB
Plaintext
.\" $Id$
|
|
.\"
|
|
.\" Copyright (c) 2016--2017, 2020 Kristaps Dzonsons <kristaps@bsd.lv>
|
|
.\"
|
|
.\" Permission to use, copy, modify, and distribute this software for any
|
|
.\" purpose with or without fee is hereby granted, provided that the above
|
|
.\" copyright notice and this permission notice appear in all copies.
|
|
.\"
|
|
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
.\"
|
|
.Dd $Mdocdate$
|
|
.Dt KHTTP_EPOCH2TMS 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm KHTTP_EPOCH2TM ,
|
|
.Nm khttp_epoch2tms
|
|
.Nd convert time to components
|
|
.Sh LIBRARY
|
|
.Lb libkcgi
|
|
.Sh SYNOPSIS
|
|
.In sys/types.h
|
|
.In stdarg.h
|
|
.In stdint.h
|
|
.In kcgi.h
|
|
.Ft int
|
|
.Fo khttp_epoch2tms
|
|
.Fa "int64_t epoch"
|
|
.Fa "int *tm_sec"
|
|
.Fa "int *tm_min"
|
|
.Fa "int *tm_hour"
|
|
.Fa "int *tm_mday"
|
|
.Fa "int *tm_mon"
|
|
.Fa "int *tm_year"
|
|
.Fa "int *tm_wday"
|
|
.Fa "int *tm_yday"
|
|
.Fc
|
|
.Ft int
|
|
.Fo KHTTP_EPOCH2TM
|
|
.Fa "int64_t epoch"
|
|
.Fa "struct tm *tm"
|
|
.Fc
|
|
.Sh DESCRIPTION
|
|
Format an
|
|
.Fa epoch
|
|
value
|
|
.Pq seconds since Jan 1, 1970, 00:00:00 UTC
|
|
into its broken-down time components suitable for
|
|
.Vt "struct tm"
|
|
operations.
|
|
.Pp
|
|
The components of
|
|
.Fn khttp_epoch2tms
|
|
are filled in as follows:
|
|
.Bl -column tm_hourx aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -offset indent
|
|
.It Fa tm_sec Ta seconds 0\(en59
|
|
.It Fa tm_min Ta minutes 0\(en59
|
|
.It Fa tm_hour Ta hours 0\(en23
|
|
.It Fa tm_day Ta day of month 1\(en31
|
|
.It Fa tm_mon Ta month 0\(en11
|
|
.It Fa tm_year Ta year minus 1900
|
|
.It Fa tm_yday Ta day in year 0\(en365
|
|
.It Fa tm_wday Ta day in week 0\(en6 (Sunday = 0)
|
|
.El
|
|
.Pp
|
|
If any of the pointers are
|
|
.Dv NULL ,
|
|
they are ignored.
|
|
.Pp
|
|
The
|
|
.Fn KHTTP_EPOCH2TM
|
|
macro fills in
|
|
.Fa tm
|
|
with the above values.
|
|
Other fields in the
|
|
.Vt "struct tm"
|
|
structure, like
|
|
.Va tm_gmtoff ,
|
|
are not touched.
|
|
.Pp
|
|
These deprecate the original
|
|
.Fn kutil_epoch2tmvals
|
|
function and
|
|
.Fn KUTIL_EPOCH2TM
|
|
macro, both of which had undefined behaviour in some corner cases.
|
|
.Pp
|
|
For conversion without possible overflow or underflow, use
|
|
.Xr khttp_epoch2datetime 3 .
|
|
.Sh RETURN VALUES
|
|
These return zero on failure and non-zero on success.
|
|
Failure occurs if
|
|
.Fa epoch
|
|
will overflow or underflow
|
|
.Fa tm_year ,
|
|
which occurs around the year \(+-6.7+16.
|
|
.Sh SEE ALSO
|
|
.Xr khttp_datetime2epoch 3 ,
|
|
.Xr khttp_epoch2datetime 3 ,
|
|
.Xr khttp_epoch2str 3
|
|
.Sh AUTHORS
|
|
Written by
|
|
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
|