Namespaces
Variants

Standard library header <time.h>

From cppreference.net

このヘッダは 日付と時間ユーティリティ ライブラリの一部です。

目次

翻訳の説明: - 「Contents」→「目次」に翻訳 - C++関連の用語(Functions, Time manipulation, Format conversions, Constants, Types, Synopsis)は原文のまま保持 - HTMLタグ、属性、クラス名、IDは一切変更せず - 番号付けや構造は完全に維持 - プロフェッショナルな技術文書としての正確性を確保

関数

時間操作
時間間の差を計算する
(関数)
エポックからの経過時間としてシステムの現在のカレンダー時間を返す
(関数)
プログラム開始からの生プロセッサクロック時間を返す
(関数)
指定された時間基準に基づいて秒とナノ秒単位のカレンダー時間を返す
(関数)
指定された時間基準に基づくカレンダー時間の分解能を返す
(関数)
フォーマット変換
(C23で非推奨) (C11)
tm オブジェクトをテキスト表現に変換する
(関数)
(C23で非推奨) (C11)
time_t オブジェクトをテキスト表現に変換する
(関数)
tm オブジェクトをカスタムテキスト表現に変換する
(関数)
エポックからの経過時間を協定世界時(UTC)で表されたカレンダー時間に変換する
(関数)
エポックからの経過時間を現地時間で表されたカレンダー時間に変換する
(関数)
カレンダー時間をエポックからの経過時間に変換する
(関数)

定数

1秒あたりのプロセッサクロックティック数
(マクロ定数)

カレンダー時間型
(構造体)
エポックからのカレンダー時間型
(typedef)
エポックからのプロセッサ時間型
(typedef)
秒とナノ秒での時間
(構造体)

概要

#define __STDC_VERSION_TIME_H__ 202311L
#define NULL           /* 説明を参照 */
#define CLOCKS_PER_SEC /* 説明を参照 */
#define TIME_UTC       /* 説明を参照 */
typedef /* 説明を参照 */ clock_t;
typedef /* 説明を参照 */ size_t;
typedef /* 説明を参照 */ time_t;
struct timespec { /* 説明を参照 */ };
struct tm { /* 説明を参照 */ };
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 /* 説明を参照 */

実装が __STDC_LIB_EXT1__ を定義しており、かつユーザーコードが <time.h> のインクルード前に __STDC_WANT_LIB_EXT1__ を定義している場合のみ:

#ifdef __STDC_WANT_LIB_EXT1__
typedef /* 詳細は説明を参照 */ errno_t;
typedef /* 詳細は説明を参照 */ 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