Standard library header <ctime>
From cppreference.net
该头文件最初作为 <time.h> 存在于C标准库中。
此头文件是 C风格日期与时间 库的组成部分。
宏常量 |
||
|
每秒处理器时钟滴答数
(宏常量) |
||
|
实现定义的空指针常量
(宏常量) |
||
类型 |
||
|
进程运行时间
(类型定义) |
||
|
sizeof
运算符返回的无符号整数类型
(类型定义) |
||
|
纪元时间类型
(类型定义) |
||
|
日历时间类型
(类) |
||
|
(C++17)
|
以秒和纳秒表示的时间
(结构体) |
|
函数 |
||
时间操作 |
||
|
返回程序启动后的原始处理器时钟时间
(函数) |
||
|
返回系统当前时间(自纪元起的时间)
(函数) |
||
|
计算时间差
(函数) |
||
|
(C++17)
|
基于给定时间基准返回以秒和纳秒表示的日历时间
(函数) |
|
格式转换 |
||
|
将
std::time_t
对象转换为文本表示
(函数) |
||
|
将
std::tm
对象转换为文本表示
(函数) |
||
|
将
std::tm
对象转换为自定义文本表示
(函数) |
||
|
将纪元时间转换为协调世界时表示的日历时间
(函数) |
||
|
将纪元时间转换为本地时间表示的日历时间
(函数) |
||
|
将日历时间转换为纪元时间
(函数) |
||
概要
#define NULL /* 参见描述 */ #define CLOCKS_PER_SEC /* 参见描述 */ #define TIME_UTC /* 参见描述 */ namespace std { using size_t = /* 参见描述 */; using clock_t = /* 参见描述 */; using time_t = /* 参见描述 */; struct timespec; struct tm; clock_t clock(); double difftime(time_t time1, time_t time0); time_t mktime(tm* timeptr); time_t time(time_t* timer); int timespec_get(timespec* ts, int base); char* asctime(const tm* timeptr); char* ctime(const time_t* timer); tm* gmtime(const time_t* timer); tm* localtime(const time_t* timer); size_t strftime(char* s, size_t maxsize, const char* format, const tm* timeptr); }
类 std::timespec
struct timespec { std::time_t tv_sec; long tv_nsec; };
类 std::tm
struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; };