xref: /netbsd-src/lib/libc/time/offtime.3 (revision 51a8d8a0b4bd98147f2d87d493fbc0f80f7d1a76)
1.\"	$NetBSD: offtime.3,v 1.4 2017/10/25 19:01:25 abhinav Exp $
2.\" Written by Klaus Klein, May 10, 2004.
3.\" Public domain.
4.Dd April 14, 2011
5.Dt OFFTIME 3
6.Os
7.Sh NAME
8.Nm offtime ,
9.Nm offtime_r ,
10.Nm timeoff ,
11.Nm timegm ,
12.Nm timelocal
13.Nd convert date and time
14.Sh LIBRARY
15.Lb libc
16.Sh SYNOPSIS
17.In time.h
18.Ft struct tm *
19.Fn offtime "const time_t * clock" "long int offset"
20.Ft struct tm *
21.Fn offtime_r "const time_t * clock" "long int offset" "struct tm *ret"
22.Ft time_t
23.Fn timeoff "struct tm * tm" "long int offset"
24.Ft time_t
25.Fn timegm "struct tm * tm"
26.Ft time_t
27.Fn timelocal "struct tm * tm"
28.Sh DESCRIPTION
29These functions are inspired by C standard interfaces named similarly.
30.Pp
31.Fn offtime
32converts the calendar time
33.Fa clock ,
34offset by
35.Fa offset
36seconds,
37into broken-down time, expressed as Coordinated Universal Time (UTC).
38.Pp
39.Fn offtime_r
40is similar to
41.Fn offtime
42but it places the returned
43.Ft "struct tm *"
44in the user supplied
45.Fa ret
46argument.
47.Pp
48.Fn timeoff
49converts the broken-down time
50.Fa tm ,
51expressed as UTC,
52offset by
53.Fa offset
54seconds,
55into a calendar time value.
56.Pp
57.Fn timegm
58converts the broken-down time
59.Fa tm
60into a calendar time value, effectively being the inverse of
61.Xr gmtime 3 .
62It is equivalent to the C standard function
63.Xr mktime 3
64operating in UTC.
65.Pp
66.Fn timelocal
67converts the broken down time
68.Fa tm ,
69expressed as local time, into a calendar time value.
70It is equivalent to the C standard function
71.Xr mktime 3 ,
72and is provided for symmetry only.
73.Sh SEE ALSO
74.Xr ctime 3 ,
75.Xr tm 3 ,
76.Xr tzset 3
77