CLOCKS_PER_SECOND
The number per second of the value returned by the clock function.
NULL
An implementation-defined null pointer constant.
clock_t
An arithmetic type capable of representing time.
time_t
An arithmetic type capable of representing time.
size_t
The unsigned integral type of the result of the sizeof operator.
struct tm
Holds the components of a calendar time, called the broken-down time. The
structure shall contain at least the following members, in any order. The
semantics of the members and their normal ranges are expressed in the comments.
int tm_sec; /* seconds after the minute - [0, 61] */
int tm_min; /* minutes after the hour - [0, 59] */
int tm_hour; /* hours since midnight - [0, 23] */
int tm_mday; /* day of the month - [1, 31] */
int tm_mon; /* months since January - [0, 11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0, 6] */
int tm_yday; /* days since January 1 - [0, 365] */
int tm_isdst; /* Daylight Savings Time flag */
The value tm_isdst is positive if Daylight Saving Time is in effect, zero
if Daylight Saving Time is not in effect, and negetive if the information is not
available.
clock_t clock(void);
The clock function determines the processor time used. The clock function
returns the implementation's best approximation to the processor time used by the
program since the beginning of an implementation-defined era related only to the
program invocation. To determine the time in seconds, the value returned by the
clock function should be divided by the value of the macro CLOCKS_PER_SECOND.
If the processor time used is not available or its value cannot be represented, the
function returns the value (clock_t)-1.
double difftime(time_t time1, time_t time0);
The difftime function computes the difference between two calendar times:
time1 - time0. The difftime function returns the difference expressed
in seconds as a double.
time_t mktime(struct tm *timeptr);
The mktime function converts the broken-down time, expressed as local time, in
the structure pointed to by timeptr into a calendar time value with the same
encoding as that of the values returned by the time function. The original
values of the tm_wday and tm_yday components of the structure are ignored,
and the original values of the other components are not restricted to the ranges
indicated above. On successful completion, the values of the tm_wday and
tm_yday components of the structure are set appropriately, and the other
components are set to represent the specified calendar time, but with their values
forced to the ranges indicated above; the final value of tm_mday is not set until
tm_mon and tm_year are determined. The mktime function returns the
specified claendar time encoded as a value of type time_t. If the calendar time
cannot be represented, the function returns the value (time_t)-1.
time_t time(time_t *timer);
The time function determines the current calendar time. The time function
returns the implementation's best approximation to the current calendar time. The
value (time_t)-1 is returned if the calendar time is not available. If timer
is not a null pointer, the return value is also assigned to the object it points to.
char *asctime(const struct tm *timeptr);
The asctime function converts the broken-down time in the structure pointed to
by timeptr into a string in the following form:
Sun Sep 16 01:03:52 1973\n\0
The asctime function returns a pointer to the string.
char *ctime(const time_t *timer);
The ctime function converts the calendar time pointed to by timer to local
time in the form of a string. It is equivalent to the following:
asctime(localtime(timer))
The ctime function returns the pointer returned by the asctime function with
that broken-down time as argument.
struct tm *gmtime(const time_t *timer);
The gmtime function converts the calendar time pointed to by timer into a
broken-down time, expressed as Coordinated Universal Time (UTC). The gmtime
function returns a pointer to that object, or a null pointer if UTC is not available.
struct tm *localtime(const time_t *timer);
The localtime function converts the calendar time pointed to by timer into
a broken-down time, expressed as local time. The localtime function returns a
pointer to that object.
size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr);
The strftime places characters into the array pointed to by s as controlled
by the string pointed to by format. The format string consists of zero or
more conversion specifiers and ordinary multibyte characters. All ordinary characters
(including the terminating null character) are copied unchanged into the array. If copying
takes place between objects that overlap, the behavior is undefined. No more than
maxsize characters are placed into the array. Each conversion specifier is
replaced by appropriate characters as described in the following list. The appropriate
characters are determined by the LC_TIME catagory of the current locale and by the
values contained in the structure pointed to by timeptr.
%a is replaced by the locale's abbreviated weekday name.
%A is replaced by the locale's full weekday name.
%b is replaced by the locale's abbreviated month name.
%B is replaced by the locale's full month name.
%c is replaced by the locale's appropriate date and time
representation.
%d is replaced by the day of the month as a decimal
number (01-31).
%H is replaced by the hour (24-hour clock) as a decimal
number (00-23).
%I is replaced by the hour (12-hour clock) as a decimal
number (01-12).
%j is replaced by the day of the year as a decimal
number (001-366).
%m is replaced by the month as a decimal number (01-12).
%M is replaced by the minute as a decimal number (00-59).
%p is replaced by the locale's equivalent of the AM/PM
designations associated with a 12-hour clock.
%S is replaced by the second as a decimal number (00-61).
%U is replaced by the week number of the year (the first
Sunday as the first day of week 1) as a decimal
number (00-53).
%w is replaced by the weekday as a decimal number (0-6),
where Sunday is 0.
%W is replaced by the week number of the year (the first
Monday as the first day of week 1) as a decimal
number (00-53).
%x is replaced by the locale's appropriate date representation.
%X is replaced by the locale's appropriate time representation.
%y is replaced by the year without century as a decimal
number (00-99).
%Y is replaced by the year with century as a decimal number.
%Z is replaced by the time zone name or abbreviation, or by no
characters if no time zone is determinable.
%% is replaced by %.
If a conversion specifier is not one of the above, the behavior is undefined. If the
total number of resulting characters including the terminating null character is not more
than maxsize, the strftime function returns the number of characters placed
into the array pointed to by s not including the terminating null character.
Otherwise, zero is returned and the contents of the array are indeterminate.