English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A seguir estão os tipos de variáveis definidos no cabeçalho time.h:
Number | Variável & Descrição |
---|---|
1 | size_t É um tipo de inteiro sem sinal, é sizeof O resultado da palavra-chave. |
2 | clock_t Este é um tipo adequado para armazenar tempo de processador. |
3 | time_t is This is suitable for storing calendar time types. |
4 | struct tm This is a structure used to save time and date. |
The definition of the tm structure is as follows:
struct tm { int tm_sec; /* Second, ranging from 0 to 59 */ int tm_min; /* Minute, ranging from 0 to 59 */ int tm_hour; /* Hour, ranging from 0 to 23 */ int tm_mday; /* Day of the month, ranging from 1 to 31 */ int tm_mon; /* Month, ranging from 0 to 11 */ int tm_year; /* Since 19Years since 00 */ int tm_wday; /* Day of the week, ranging from 0 to 6 */ int tm_yday; /* Day of the year, ranging from 0 to 365 */ int tm_isdst; /* Daylight Saving Time */ };
The following are the macros defined in the header file time.h:
Number | Macro & Description |
---|---|
1 | NULL This macro is the value of a null pointer constant. |
2 | CLOCKS_PER_SEC This macro represents the number of processor clock cycles per second. |
The following are the functions defined in the header file time.h:
Number | Function & Description |
---|---|
1 | char *asctime(const struct tm *timeptr) Returns a pointer to a string that represents the date and time of the structure timeptr. |
2 | clock_t clock(void) Returns the time used by the processor clock since the start of program execution (usually at the beginning of the program). |
3 | char *ctime(const time_t *timer) Returns a string representing the local time, based on the parameter timer. |
4 | double difftime(time_t time12, time_t time )1 Returns time2 and time1-The difference in seconds between (time2time |
5 | struct tm *)。 *timer) The value of the timer is decomposed into a tm structure and represented in Coordinated Universal Time (UTC), also known as Greenwich Mean Time (GMT). |
6 | struct tm *localtime(const time_t *timer) The value of the timer is decomposed into a tm structure and represented in the local time zone. |
7 | time_t mktime(struct tm *timeptr) Convert the structure pointed to by timeptr to a time_t value based on the local time zone. |
8 | size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) Formatar a estrutura de tempo representada pelo timeptr com base nas regras de formatação definidas no format, e armazená-la em str. |
9 | time_t time(time_t *timer) Calcular a data do calendário atual e codificá-la no formato time_t. |