time.h 头定义了四个变量类型,两个宏和用于操作的日期和时间的各种功能。
库变量
以下是在头time.h中定义的变量类型:
S.N. | 变量和说明 |
1 | size_t |
2 | clock_t |
3 | time_t is |
4 | struct tm |
tm结构具有下列定义:
struct tm{
int tm_sec; /* seconds, range 0 to 59 */
int tm_min; /* minutes, range 0 to 59 */
int tm_hour; /* hours, range 0 to 23 */
int tm_mday; /* day of the month, range 1 to 31 */
int tm_mon; /* month, range 0 to 11 */
int tm_year; /* The number of years since 1900 */
int tm_wday; /* day of the week, range 0 to 6 */
int tm_yday; /* day in the year, range 0 to 365 */
int tm_isdst; /* daylight saving time */
};
库宏
以下是在头time.h中定义的宏:
S.N. | 宏观与说明 |
1 | NULL |
2 | CLOCKS_PER_SEC |
库函数
以下是在头time.h中定义的函数:
S.N. | 函数及说明 |
1 | char *asctime(const struct tm *timeptr) |
2 | clock_t clock(void) |
3 | char *ctime(const time_t *timer) |
4 | double difftime(time_t time1, time_t time2) |
5 | struct tm *gmtime(const time_t *timer) |
6 | struct tm *localtime(const time_t *timer) |
7 | time_t mktime(struct tm *timeptr) |
8 | size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) |
9 | time_t time(time_t *timer) |