The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


time.h - time types


#include <time.h>


The <time.h> header declares the structure tm, which includes at least the following members:

int    tm_sec   seconds [0,61]
int    tm_min   minutes [0,59]
int    tm_hour  hour [0,23]
int    tm_mday  day of month [1,31]
int    tm_mon   month of year [0,11]
int    tm_year  years since 1900
int    tm_wday  day of week [0,6] (Sunday = 0)
int    tm_yday  day of year [0,365]
int    tm_isdst daylight savings flag

The value of tm_isdst is positive if Daylight Saving Time is in effect, 0 if Daylight Saving Time is not in effect, and negative if the information is not available.

This header defines the following symbolic names:

Null pointer constant.
Number of clock ticks per second returned by the times() function (LEGACY).
A number used to convert the value returned by the clock() function into seconds.

The <time.h> header declares the structure timespec, which has at least the following members:

time_t  tv_sec    seconds
long    tv_nsec   nanoseconds

This header also declares the itimerspec structure, which has at least the following members:

struct timespec  it_interval  timer period
struct timespec  it_value     timer expiration

The following manifest constants are defined:

The identifier of the systemwide realtime clock.
Flag indicating time is absolute with respect to the clock associated with a timer.

The clock_t, clockid_t, size_t, time_t and timer_t types are defined as described in <sys/types.h>.

Although the value of CLOCKS_PER_SEC is required to be 1 million on all XSI-conformant systems, it may be variable on other systems and it should not be assumed that CLOCKS_PER_SEC is a compile-time constant.

The value of CLK_TCK is currently the same as the value of sysconf(_SC_CLK_TCK); however, new applications should call sysconf() because the CLK_TCK macro may be withdrawn in a future issue.

The <time.h> header provides a declaration for getdate_err.

The following are declared as functions and may also be defined as macros. Function prototypes must be provided for use with an ISO C compiler.

char      *asctime(const struct tm *);
char      *asctime_r(const struct tm *, char *);
clock_t    clock(void);
int        clock_getres(clockid_t, struct timespec *);
int        clock_gettime(clockid_t, struct timespec *);
int        clock_settime(clockid_t, const struct timespec *);
char      *ctime(const time_t *);
char      *ctime_r(const time_t *, char *);
double     difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *gmtime_r(const time_t *, struct tm *);
struct tm *localtime(const time_t *);
struct tm *localtime_r(const time_t *, struct tm *);
time_t     mktime(struct tm *);
int        nanosleep(const struct timespec *, struct timespec *);
size_t     strftime(char *, size_t, const char *, const struct tm *);
char      *strptime(const char *, const char *, struct tm *);
time_t     time(time_t *);
int        timer_create(clockid_t, struct sigevent *, timer_t *);
int        timer_delete(timer_t);
int        timer_gettime(timer_t, struct itimerspec *);
int        timer_getoverrun(timer_t);
int        timer_settime(timer_t, int, const struct itimerspec *,
               struct itimerspec *);
void       tzset(void);

The following are declared as variables:

extern int       daylight;
extern long int  timezone;
extern char     *tzname[];


The range [0,61] for tm_sec allows for the occasional leap second or double leap second.

tm_year is a signed value, therefore years before 1900 may be represented.

The functions clock_getres(), clock_gettime(), clock_settime(), nanosleep(), timer_create(), timer_delete(), timer_getoverrun(), timer_gettime(), and timer_settime() are part of the Realtime Feature Group.




asctime(), asctime_r(), clock(), clock_settime(), ctime(), ctime_r(), daylight, difftime(), getdate(), gmtime(), gmtime_r(), localtime(), localtime_r(), mktime(), nanosleep(), strftime(), strptime(), sysconf(), time(), timer_create(), timer_delete(), timer_settime(), timezone, tzname(), tzset(), utime().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]