Blame man2/time.2

Packit 7cfc04
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" Modified by Michael Haardt <michael@moria.de>
Packit 7cfc04
.\" Modified Sat Jul 24 14:13:40 1993 by Rik Faith <faith@cs.unc.edu>
Packit 7cfc04
.\" Additions by Joseph S. Myers <jsm28@cam.ac.uk>, 970909
Packit 7cfc04
.\"
Packit 7cfc04
.TH TIME 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
time \- get time in seconds
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <time.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "time_t time(time_t *" tloc );
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR time ()
Packit 7cfc04
returns the time as the number of seconds since the
Packit 7cfc04
Epoch, 1970-01-01 00:00:00 +0000 (UTC).
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I tloc
Packit 7cfc04
is non-NULL,
Packit 7cfc04
the return value is also stored in the memory pointed to by
Packit 7cfc04
.IR tloc .
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, the value of time in seconds since the Epoch is returned.
Packit 7cfc04
On error, \fI((time_t)\ \-1)\fP is returned, and \fIerrno\fP is set
Packit 7cfc04
appropriately.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
.I tloc
Packit 7cfc04
points outside your accessible address space (but see BUGS).
Packit 7cfc04
.IP
Packit 7cfc04
On systems where the C library
Packit 7cfc04
.BR time ()
Packit 7cfc04
wrapper function invokes an implementation provided by the
Packit 7cfc04
.BR vdso (7)
Packit 7cfc04
(so that there is no trap into the kernel),
Packit 7cfc04
an invalid address may instead trigger a
Packit 7cfc04
.B SIGSEGV
Packit 7cfc04
signal.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
Packit 7cfc04
.\" Under 4.3BSD, this call is obsoleted by
Packit 7cfc04
.\" .BR gettimeofday (2).
Packit 7cfc04
POSIX does not specify any error conditions.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
POSIX.1 defines
Packit 7cfc04
.I seconds since the Epoch
Packit 7cfc04
using a formula that approximates the number of seconds between a
Packit 7cfc04
specified time and the Epoch.
Packit 7cfc04
This formula takes account of the facts that
Packit 7cfc04
all years that are evenly divisible by 4 are leap years,
Packit 7cfc04
but years that are evenly divisible by 100 are not leap years
Packit 7cfc04
unless they are also evenly divisible by 400,
Packit 7cfc04
in which case they are leap years.
Packit 7cfc04
This value is not the same as the actual number of seconds between the time
Packit 7cfc04
and the Epoch, because of leap seconds and because system clocks are not
Packit 7cfc04
required to be synchronized to a standard reference.
Packit 7cfc04
The intention is that the interpretation of seconds since the Epoch values be
Packit 7cfc04
consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.
Packit 7cfc04
.PP
Packit 7cfc04
On Linux, a call to
Packit 7cfc04
.BR time ()
Packit 7cfc04
with
Packit 7cfc04
.I tloc
Packit 7cfc04
specified as NULL cannot fail with the error
Packit 7cfc04
.BR EOVERFLOW ,
Packit 7cfc04
even on ABIs where
Packit 7cfc04
.I time_t
Packit 7cfc04
is a signed 32-bit integer and the clock ticks past the time 2**31
Packit 7cfc04
(2038-01-19 03:14:08 UTC, ignoring leap seconds).
Packit 7cfc04
(POSIX.1 permits, but does not require, the
Packit 7cfc04
.B EOVERFLOW
Packit 7cfc04
error in the case where the seconds since the Epoch will not fit in
Packit 7cfc04
.IR time_t .)
Packit 7cfc04
Instead, the behavior on Linux is undefined when the system time is out of the
Packit 7cfc04
.I time_t
Packit 7cfc04
range.
Packit 7cfc04
Applications intended to run after 2038 should use ABIs with
Packit 7cfc04
.I time_t
Packit 7cfc04
wider than 32 bits.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
Error returns from this system call are indistinguishable from
Packit 7cfc04
successful reports that the time is a few seconds
Packit 7cfc04
.I before
Packit 7cfc04
the Epoch, so the C library wrapper function never sets
Packit 7cfc04
.I errno
Packit 7cfc04
as a result of this call.
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I tloc
Packit 7cfc04
argument is obsolescent and should always be NULL in new code.
Packit 7cfc04
When
Packit 7cfc04
.I tloc
Packit 7cfc04
is NULL, the call cannot fail.
Packit 7cfc04
.\"
Packit 7cfc04
.SS C library/kernel differences
Packit 7cfc04
On some architectures, an implementation of
Packit 7cfc04
.BR time ()
Packit 7cfc04
is provided in the
Packit 7cfc04
.BR vdso (7).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR date (1),
Packit 7cfc04
.BR gettimeofday (2),
Packit 7cfc04
.BR ctime (3),
Packit 7cfc04
.BR ftime (3),
Packit 7cfc04
.BR time (7),
Packit 7cfc04
.BR vdso (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.