1.\"	$MirOS: src/lib/libc/gen/time.3,v 1.3 2005/09/22 20:40:01 tg Exp $
2.\"	$OpenBSD: time.3,v 1.11 2005/07/22 03:16:58 jaredy Exp $
3.\"
4.\" Copyright (c) 1989, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the American National Standards Committee X3, on Information
9.\" Processing Systems.
10.\"
11.\" Redistribution and use in source and binary forms, with or without
12.\" modification, are permitted provided that the following conditions
13.\" are met:
14.\" 1. Redistributions of source code must retain the above copyright
15.\"    notice, this list of conditions and the following disclaimer.
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\"    notice, this list of conditions and the following disclaimer in the
18.\"    documentation and/or other materials provided with the distribution.
19.\" 3. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.Dd June 4, 1993
36.Dt TIME 3
37.Os
38.Sh NAME
39.Nm time
40.Nd get time of day
41.Sh SYNOPSIS
42.Fd #include <time.h>
43.Ft time_t
44.Fn time "time_t *tloc"
45.Sh DESCRIPTION
46The
47.Fn time
48function returns the value of time in seconds since 0 hours, 0 minutes,
490 seconds, January 1, 1970 ("the Epoch"), Temps Atomique International
50(TAI), counting leap seconds.
51.Pp
52A copy of the time value may be saved to the area indicated by the
53pointer
54.Fa tloc .
55If
56.Fa tloc
57is a null pointer, no value is stored.
58.Pp
59Upon successful completion,
60.Fn time
61returns the value of time.
62Otherwise a value of
63.Po Fa time_t Pc Ns -1
64is returned and the global variable
65.Va errno
66is set to indicate the error.
67.Sh ERRORS
68The following error codes may be set in
69.Va errno :
70.Bl -tag -width Er
71.It Bq Er EFAULT
72An argument address referenced invalid memory.
73.El
74.Sh SEE ALSO
75.Xr gettimeofday 2 ,
76.Xr ctime 3
77.Sh HISTORY
78A
79.Fn time
80function appeared in
81.At v2
82and used to return time in sixtieths of a second in 32 bits,
83which was to guarantee a crisis every 2.26 years.
84Since
85.At v6 ,
86.Fn time
87scale was changed to seconds, extending the pre-crisis stagnation
88period up to a total of 68 years.
89.Pp
90On
91.Mx ,
92the value equals the kernel time, or the result of
93.Xr gettimeofday 2
94with no timezone information provided.
95Counting leap seconds, instead of jumping over them, while
96calculating the result, violates POSIX, but is the only way
97to get legal and lawful time.
98.Pp
99Since
100.Mx 8 ,
101the
102.Ft time_t
103type has been extended to 64 bit in order to prevent
104the year 2036 and 2038 crisises.
105