標準庫標頭檔案 <time.h>
來自 cppreference.com
此標頭檔案是日期和時間工具庫的一部分。
目錄 |
[編輯] 函式
時間操作 | |
計算時間差 (函式) | |
返回系統當前日曆時間,自紀元起的時間 (函式) | |
返回程式啟動以來原始處理器時鐘時間 (函式) | |
(C11) |
根據給定時間基準返回以秒和納秒錶示的日曆時間 (函式) |
(C23) |
根據給定時間基準返回日曆時間的解析度 (函式) |
格式轉換 | |
(C23 中已廢棄)(C11) |
將 tm 物件轉換為文字表示 (函式) |
(C23 中已廢棄)(C11) |
將 time_t 物件轉換為文字表示形式 (函式) |
將 tm 物件轉換為自定義文字表示形式 (函式) | |
(C23)(C11) |
將自紀元以來的時間轉換為協調世界時 (UTC) 表示的日曆時間 (函式) |
(C23)(C11) |
將自紀元以來的時間轉換為以本地時間表示的日曆時間 (函式) |
將日曆時間轉換為自紀元以來的時間 (函式) |
[編輯] 常量
每秒的處理器時鐘節拍數 (宏常量) |
[編輯] 型別
日曆時間型別 (結構體) | |
自紀元以來的日曆時間型別 (型別定義) | |
自紀元以來的處理器時間型別 (型別定義) | |
(C11) |
秒和納秒時間 (結構體) |
[編輯] 概要
#define __STDC_VERSION_TIME_H__ 202311L #define NULL /* see description */ #define CLOCKS_PER_SEC /* see description */ #define TIME_UTC /* see description */ typedef /* see description */ clock_t; typedef /* see description */ size_t; typedef /* see description */ time_t; struct timespec { /* see description */ }; struct tm { /* see description */ }; 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 /* see description */
僅當實現定義了 __STDC_LIB_EXT1__ 且使用者程式碼在包含 <time.h> 之前定義了 __STDC_WANT_LIB_EXT1__ 時
#ifdef __STDC_WANT_LIB_EXT1__ typedef /* see description */ errno_t; typedef /* see description */ 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