標準ライブラリヘッダー <time.h>
From cppreference.com
このヘッダーは、日付と時刻ユーティリティライブラリの一部です。
目次 |
[編集] 関数
時刻操作 | |
| 時刻間の差を計算する (関数) | |
| エポックからの時間としてシステムの現在のカレンダー時間を返す (関数) | |
| プログラム開始からのプロセッサクロックの生時間を返す (関数) | |
| (C11) |
与えられた時間基準に基づいて、カレンダー時間を秒とナノ秒で返す (関数) |
| (C23) |
与えられた時間基準に基づいて、カレンダー時間の分解能を返す (関数) |
書式変換 | |
| (C23で非推奨)(C11) |
tm オブジェクトをテキスト表現に変換する (関数) |
| (C23で非推奨)(C11) |
time_t オブジェクトをテキスト表現に変換する (関数) |
| tm オブジェクトをカスタムのテキスト表現に変換する (関数) | |
| (C23)(C11) |
エポックからの時間を、協定世界時 (UTC) で表されるカレンダー時間に変換する (関数) |
| (C23)(C11) |
エポックからの時間を、地方時で表されるカレンダー時間に変換する (関数) |
| カレンダー時間をエポックからの時間に変換する (関数) | |
[編集] 定数
| 1秒あたりのプロセッサクロックティック数 (マクロ定数) |
[編集] 型
| カレンダー時間型 (構造体) | |
| エポックからのカレンダー時刻型 (typedef) | |
| 時代からのプロセッサ時間型 (typedef) | |
| (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