CppDS.com

C++ 98 11 14 17 20 手册

标准库头文件 <ctime>

来自cppreference.com
< cpp‎ | header
 
 
 

此头文件原作为 <time.h> 存在于 C 标准库。

此头文件是 C 风格日期和时间库的一部分。

宏常量

每秒的处理器始时钟嘀嗒数
(宏常量)
实现定义的空指针常量
(宏常量)

类型

进程运行时间
(typedef)
sizeof 运算符返回的无符号整数类型
(typedef)
从纪元起的时间类型
(typedef)
日历时间类型
(类)
(C++17)
以秒和纳秒表示的时间
(结构体)

函数

时间操纵
返回自程序启动时起的原始处理器时钟时间
(函数)
返回自纪元起计的系统当前时间
(函数)
计算时间之间的差
(函数)
返回基于给定时间基底的日历时间
(函数)
格式转换
转换 time_t 对象为文本表示
(函数)
转换 tm 对象为文本表示
(函数)
转换 tm 对象到自定义的文本表示
(函数)
转换 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(struct tm* timeptr);
  time_t time(time_t* timer);
  int timespec_get(timespec* ts, int base);
  char* asctime(const struct tm* timeptr);
  char* ctime(const time_t* timer);
  struct tm* gmtime(const time_t* timer);
  struct tm* localtime(const time_t* timer);
  size_t strftime(char* s, size_t maxsize, const char* format, const struct 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;
};
关闭