标准库头文件 <ctime>_C++中文网

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

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

宏常量

类型

函数

时间操纵
返回自程序启动时起的原始处理器时钟时间
(函数)
返回自纪元起计的系统当前时间
(函数)
计算时间之间的差
(函数)
返回基于给定时间基底的日历时间
(函数)
格式转换
转换 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

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;
};