The time.h header defines four variable types, two macro and various functions for manipulating date and time.
Library Variables
size_t
This is the unsigned integral type and is the result of the sizeof keyword.
clock_t
This is a type suitable for storing the processor time.
time_t is
This is a type suitable for storing the calendar time.
struct tm
This is a structure used to hold the time and date.
Library Macros
NULL
This macro is the value of a null pointer constant.
CLOCKS_PER_SEC
This macro represents the number of processor clocks per second.
Library Functions
char *asctime(const struct tm *timeptr)
Returns a pointer to a string which represents the day and time of the structure timeptr.
clock_t clock(void)
Returns the processor clock time used since the beginning of an implementation defined era (normally the beginning of the program).
char *ctime(const time_t *timer)
Returns a string representing the localtime based on the argument timer.
double difftime(time_t time1, time_t time2)
Returns the difference of seconds between time1 and time2 (time1-time2).
struct tm *gmtime(const time_t *timer)
The value of timer is broken up into the structure tm and expressed in Coordinated Universal Time (UTC) also known as Greenwich Mean Time (GMT).
struct tm *localtime(const time_t *timer)
The value of timer is broken up into the structure tm and expressed in the local time zone.
time_t mktime(struct tm *timeptr)
Converts the structure pointed to by timeptr into a time_t value according to the local time zone.
size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr)
Formats the time represented in the structure timeptr according to the formatting rules defined in format and stored into str.
time_t time(time_t *timer)
Calculates the current calender time and encodes it into time_t format.
Không có nhận xét nào:
Đăng nhận xét