Node:Simple Calendar Time, Next:High-Resolution Calendar, Up:Calendar Time
This section describes the time_t
data type for representing calendar
time as simple time, and the functions which operate on simple time objects.
These facilities are declared in the header file time.h
.
time_t | Data Type |
This is the data type used to represent simple time. Sometimes, it also
represents an elapsed time. When interpreted as a calendar time value,
it represents the number of seconds elapsed since 00:00:00 on January 1,
1970, Coordinated Universal Time. (This calendar time is sometimes
referred to as the epoch.) POSIX requires that this count not
include leap seconds, but on some systems this count includes leap seconds
if you set TZ to certain values (see TZ Variable).
Note that a simple time has no concept of local time zone. Calendar Time T is the same instant in time regardless of where on the globe the computer is. In the GNU C library, |
The function difftime
tells you the elapsed time between two
simple calendar times, which is not always as easy to compute as just
subtracting. See Elapsed Time.
time_t time (time_t *result) | Function |
The time function returns the current calendar time as a value of
type time_t . If the argument result is not a null pointer,
the calendar time value is also stored in *result . If the
current calendar time is not available, the value
(time_t)(-1) is returned.
|
int stime (time_t *newtime) | Function |
stime sets the system clock, i.e. it tells the system that the
current calendar time is newtime, where newtime is
interpreted as described in the above definition of time_t .
Only the superuser can set the system clock. If the function succeeds, the return value is zero. Otherwise, it is
|