std::chrono:: current_zone
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<chrono>
|
||
|
const
std::
chrono
::
time_zone
*
current_zone
(
)
;
|
(C++20以降) | |
タイムゾーンデータベースからローカルタイムゾーンを取得するための便利関数。 タイムゾーンデータベース から取得します。 std:: chrono :: get_tzdb ( ) . current_zone ( ) と同等です。
目次 |
例外
std::runtime_error タイムゾーンデータベースへの最初の参照であり、かつタイムゾーンデータベースを初期化できない場合。
注記
この関数の呼び出しがタイムゾーンデータベースへの最初の参照である場合、データベースの初期化が行われます。
例
このコードを実行
#include <chrono> #include <iostream> int main() { try { const std::chrono::zoned_time cur_time { std::chrono::current_zone(), // may throw std::chrono::system_clock::now() }; std::cout << cur_time << '\n'; } catch(const std::runtime_error& ex) { std::cerr << ex.what() << '\n'; } }
出力例:
2021-09-13 19:46:42.249182012 MAGT
関連項目
|
ローカルタイムゾーンを返す
(
std::chrono::tzdb
の公開メンバ関数)
|
|
|
グローバルタイムゾーンデータベース情報へのアクセスと制御
(関数) |