Standard library header <time.h>
From cppreference.net
此头文件属于 日期与时间工具库 。
目录 |
函数
时间操作 |
|
|
计算时间差
(函数) |
|
|
返回系统当前日历时间(自纪元起的时间)
(函数) |
|
|
返回程序启动后的原始处理器时钟时间
(函数) |
|
|
(C11)
|
基于给定时间基准返回以秒和纳秒为单位的日历时间
(函数) |
|
(C23)
|
基于给定时间基准返回日历时间分辨率
(函数) |
格式转换 |
|
|
(C23 中弃用)
(C11)
|
将
tm
对象转换为文本表示形式
(函数) |
|
(C23 中弃用)
(C11)
|
将
time_t
对象转换为文本表示形式
(函数) |
|
将
tm
对象转换为自定义文本表示形式
(函数) |
|
|
(C23)
(C11)
|
将自纪元起的时间转换为协调世界时(UTC)表示的日历时间
(函数) |
|
(C23)
(C11)
|
将自纪元起的时间转换为本地时间表示的日历时间
(函数) |
|
将日历时间转换为自纪元起的时间
(函数) |
|
常量
|
处理器时钟每秒滴答次数
(宏常量) |
类型
|
日历时间类型
(结构体) |
|
|
自纪元起的日历时间类型
(类型定义) |
|
|
自纪元起的处理器时间类型
(类型定义) |
|
|
(C11)
|
以秒和纳秒表示的时间
(结构体) |
概要
#define __STDC_VERSION_TIME_H__ 202311L #define NULL /* 查看描述 */ #define CLOCKS_PER_SEC /* 查看描述 */ #define TIME_UTC /* 查看描述 */ typedef /* 查看描述 */ clock_t; typedef /* 查看描述 */ size_t; typedef /* 查看描述 */ time_t; struct timespec { /* 查看描述 */ }; struct tm { /* 查看描述 */ }; clock_t clock(void); double difftime(time_t time1, time_t time0); time_t mktime(struct tm* timeptr); time_t timegm(struct tm* timeptr); time_t time(time_t* timer); int timespec_get(struct timespec* ts, int base); int timespec_getres(struct timespec* ts, int base); [[deprecated]] char* asctime(const struct tm* timeptr); [[deprecated]] char* ctime(const time_t* timer); struct tm* gmtime(const time_t* timer); struct tm* gmtime_r(const time_t* timer, struct tm* buf); struct tm* localtime(const time_t* timer); struct tm* localtime_r(const time_t* timer, struct tm* buf); size_t strftime(char* restrict s, size_t maxsize, const char* restrict format, const struct tm* restrict timeptr);
仅当实现支持时:
#define TIME_MONOTONIC /* see description */ #define TIME_ACTIVE /* see description */
仅当支持线程且实现支持时:
#define TIME_THREAD_ACTIVE /* 查看描述 */
仅当实现定义了 __STDC_LIB_EXT1__ 且用户代码在包含 <time.h> 之前额外定义了 __STDC_WANT_LIB_EXT1__ 时:
#ifdef __STDC_WANT_LIB_EXT1__ typedef /* 见描述 */ errno_t; typedef /* 见描述 */ rsize_t; errno_t asctime_s(char* s, rsize_t maxsize, const struct tm* timeptr); errno_t ctime_s(char* s, rsize_t maxsize, const time_t* timer); struct tm* gmtime_s(const time_t* restrict timer, struct tm* restrict result); struct tm* localtime_s(const time_t* restrict timer, struct tm* restrict result); #endif