tools
読み取り中…
検索中…
一致する文字列を見つけられません
time.h ファイル

時刻・時間ユーティリティ [詳解]

#include <string>
#include <ctime>
#include <sstream>
#include <iomanip>
#include <array>
#include <chrono>
#include <thread>
time.h の依存先関係図:
被依存関係図:

[ソースコード]

列挙型

enum class  tu {
  n , c , l , s ,
  m , h , d , o ,
  y
}
 時間単位を表す列挙型 [詳解]

関数

void sleepc (tu unit, double value)
 指定した時間単位でスレッドをスリープさせる
std::string getCTime (const std::string format)
 現在のローカル時刻を指定フォーマットの文字列で返す
int64_t getUnixTime ()
 現在の Unix タイムスタンプ(秒)を返す
int getCTime (const tu unit)
 指定した時間単位の現在値をローカル時刻から返す
std::array< int, 3 > splitTime (int total_seconds)
 秒数を 時間・分・秒 の配列に分割する

詳解

時刻・時間ユーティリティ

時間単位の列挙型 (tu)、スリープ関数、現在時刻の取得・フォーマット、 Unix タイムスタンプ取得、秒数を時分秒に分割する関数を提供します。

time.h に定義があります。

列挙型詳解

◆ tu

enum class tu
strong

時間単位を表す列挙型

sleepc()getCTime() などの時間関数に渡す単位を指定します。

列挙値

ナノ秒

マイクロ秒

ミリ秒

時間

time.h24 行目に定義があります。

関数詳解

◆ getCTime() [1/2]

std::string getCTime ( const std::string format)
inline

現在のローカル時刻を指定フォーマットの文字列で返す

引数
formatstrftime 書式文字列(例: "%Y-%m-%d %H:%M:%S")
戻り値
フォーマットされた現在時刻文字列

time.h59 行目に定義があります。

◆ getCTime() [2/2]

int getCTime ( const tu unit)
inline

指定した時間単位の現在値をローカル時刻から返す

引数
unit取得する時間単位(tu::s / tu::m / tu::h / tu::d / tu::o / tu::y)
戻り値
対応する時刻フィールドの整数値(年は西暦、月は 1〜12、日は 1〜31)
例外
std::invalid_argumentサポートされていない単位が渡された場合

time.h80 行目に定義があります。

◆ getUnixTime()

int64_t getUnixTime ( )
inline

現在の Unix タイムスタンプ(秒)を返す

戻り値
エポック(1970-01-01 00:00:00 UTC)からの経過秒数

time.h70 行目に定義があります。

◆ sleepc()

void sleepc ( tu unit,
double value )
inline

指定した時間単位でスレッドをスリープさせる

引数
unit時間単位 (tu::n / tu::c / tu::l / tu::s / tu::m / tu::h)
valueスリープする時間の値
例外
std::invalid_argumentサポートされていない単位 (d / o / y) が渡された場合

time.h42 行目に定義があります。

被呼び出し関係図:

◆ splitTime()

std::array< int, 3 > splitTime ( int total_seconds)
inline

秒数を 時間・分・秒 の配列に分割する

引数
total_seconds分割する総秒数
戻り値
{時間, 分, 秒} の順に格納した 3 要素の配列

time.h99 行目に定義があります。