diff --git a/reference/chrono/gps_clock.md b/reference/chrono/gps_clock.md index a383403a7c..3cdab5a04c 100644 --- a/reference/chrono/gps_clock.md +++ b/reference/chrono/gps_clock.md @@ -72,7 +72,7 @@ int main() ### 出力例 ``` -2019-10-24 11:15:37 GPS +2019-10-24 11:15:37.493236171 ``` ## バージョン @@ -81,7 +81,7 @@ int main() ### 処理系 - [Clang](/implementation.md#clang): 9.0 [mark noimpl] -- [GCC](/implementation.md#gcc): 9.2 [mark noimpl] +- [GCC](/implementation.md#gcc): 9.2 [mark noimpl], 13.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2019 Update 3 [mark noimpl] diff --git a/reference/chrono/gps_clock/from_utc.md b/reference/chrono/gps_clock/from_utc.md index 4f33d3ecb2..472cec2792 100644 --- a/reference/chrono/gps_clock/from_utc.md +++ b/reference/chrono/gps_clock/from_utc.md @@ -50,18 +50,17 @@ using namespace std::chrono_literals; int main() { - // ここでは日単位のシステム時間を、utc_clockを経由して、日単位のGPS時間に変換している。 - // 秒単位の時間を渡せば、秒単位のGPS時間が返る - auto st = chrono::sys_days{2019y/10/24}; - auto ut = chrono::utc_clock::from_sys(st); - auto tt = chrono::gps_clock::from_utc(ut); // 日単位のGPS時間が返る + // ここでは日単位のシステム時間を、秒単位のUTC時間とGPS時間に変換している。 + auto st = chrono::sys_days{2019y/10/24}; // システム時間,日単位 + auto ut = chrono::utc_clock::from_sys(st); // UTC時間,秒単位 + auto tt = chrono::gps_clock::from_utc(ut); // GPS時間,秒単位 - // うるう秒 + // UTC時間のうるう秒に関する情報 chrono::leap_second_info info = chrono::get_leap_second_info(ut); std::cout << st << std::endl; - std::cout << ut << std::endl; - std::cout << tt << std::endl; + std::cout << ut << " UTC" << std::endl; + std::cout << tt << " GPS" << std::endl; std::cout << info.elapsed.count() << std::endl; } ``` @@ -76,9 +75,9 @@ int main() ### 出力 ``` -2019-10-24 00:00:00 +2019-10-24 2019-10-24 00:00:00 UTC -2019-10-24 00:00:27 GPS +2019-10-24 00:00:18 GPS 27 ``` @@ -88,5 +87,5 @@ int main() ### 処理系 - [Clang](/implementation.md#clang): 9.0 [mark noimpl] -- [GCC](/implementation.md#gcc): 9.2 [mark noimpl] +- [GCC](/implementation.md#gcc): 9.2 [mark noimpl], 13.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2019 Update 3 [mark noimpl] diff --git a/reference/chrono/gps_clock/now.md b/reference/chrono/gps_clock/now.md index 7c99542b13..3d77f6efad 100644 --- a/reference/chrono/gps_clock/now.md +++ b/reference/chrono/gps_clock/now.md @@ -38,7 +38,7 @@ int main() ### 出力例 ``` -2019-10-24 11:15:37 GPS +2019-10-24 11:15:51.428340077 ``` ## バージョン @@ -47,5 +47,5 @@ int main() ### 処理系 - [Clang](/implementation.md#clang): 9.0 [mark noimpl] -- [GCC](/implementation.md#gcc): 9.2 [mark noimpl] +- [GCC](/implementation.md#gcc): 9.2 [mark noimpl], 13.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2019 Update 3 [mark noimpl] diff --git a/reference/chrono/gps_clock/to_utc.md b/reference/chrono/gps_clock/to_utc.md index 30b53663ae..1bc92cf475 100644 --- a/reference/chrono/gps_clock/to_utc.md +++ b/reference/chrono/gps_clock/to_utc.md @@ -57,8 +57,8 @@ int main() // うるう秒 chrono::leap_second_info info = chrono::get_leap_second_info(ut); - std::cout << tt << std::endl; - std::cout << ut << std::endl; + std::cout << tt << " GPS" << std::endl; + std::cout << ut << " UTC" << std::endl; std::cout << info.elapsed.count() << std::endl; } ``` @@ -73,7 +73,7 @@ int main() ### 出力 ``` -2019-10-24 00:00:27 GPS +2019-10-24 00:00:18 GPS 2019-10-24 00:00:00 UTC 27 ``` @@ -84,5 +84,5 @@ int main() ### 処理系 - [Clang](/implementation.md#clang): 9.0 [mark noimpl] -- [GCC](/implementation.md#gcc): 9.2 [mark noimpl] +- [GCC](/implementation.md#gcc): 9.2 [mark noimpl], 13.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2019 Update 3 [mark noimpl] diff --git a/reference/chrono/gps_time.md b/reference/chrono/gps_time.md index c378e5d4e6..4d765cffeb 100644 --- a/reference/chrono/gps_time.md +++ b/reference/chrono/gps_time.md @@ -105,7 +105,7 @@ int main() #### 出力例 ``` -2019-10-24 11:15:27 GPS +2019-10-24 11:15:27 ``` ### 入力の例 @@ -128,8 +128,7 @@ int main() if (ss) { std::cout << tp << std::endl; - } - else { + } else { std::cout << "解析失敗" << std::endl; } } @@ -137,23 +136,27 @@ int main() // タイムゾーンを含む入力 { std::stringstream ss; - ss << "2019-10-24 20:15:10 GPS"; + ss << "2019-10-24 20:15:27 GPS"; chrono::gps_seconds tp; std::string abbrev; - chrono::from_stream(ss, "%Y-%m-%d %H:%M:%S %Z%z", tp, &abbrev); + chrono::from_stream(ss, "%Y-%m-%d %H:%M:%S %Z", tp, &abbrev); - std::cout << tp << std::endl; - std::cout << abbrev << std::endl; + if (ss) { + std::cout << tp << std::endl; + std::cout << abbrev << std::endl; + } else { + std::cout << "解析失敗" << std::endl; + } } } ``` * chrono::from_stream[color ff0000] -#### 出力例 +#### 出力 ``` -2019-10-24 11:15:27 GPS -2019-10-24 11:15:27 GPS +2019-10-24 20:15:45 +2019-10-24 20:15:45 GPS ``` @@ -168,7 +171,7 @@ namespace chrono = std::chrono; int main() { chrono::gps_clock::time_point now = chrono::gps_clock::now(); - chrono::gps_seconds now_sec = chrono::floor(tp); + chrono::gps_seconds now_sec = chrono::floor(now); // デフォルトフォーマット std::cout << std::format("1 : {}", now_sec) << std::endl; @@ -177,15 +180,15 @@ int main() std::cout << std::format("2 : {:%Y年%m月%d日 %H時%M分%S秒}", now_sec) << std::endl; // 日付を / (スラッシュ) 区切り、時間を : (コロン) 区切り、タイムゾーンの略称付き - std::cout << std::format("3 : {0:%Y/%m/%d %H:%M:%S %Z}", now_sec) << std::endl; + std::cout << std::format("3 : {:%Y/%m/%d %H:%M:%S %Z}", now_sec) << std::endl; // 日付だけ出力 - std::cout << std::format("4 : %Y年%m月%d日", now_sec) << std::endl; - std::cout << std::format("5 : %F", now_sec) << std::endl; + std::cout << std::format("4 : {:%Y年%m月%d日}", now_sec) << std::endl; + std::cout << std::format("5 : {:%F}", now_sec) << std::endl; // 時間だけ出力 - std::cout << std::format("6 : %H時%M分%S秒", now_sec) << std::endl; - std::cout << std::format("7 : %T", now_sec) << std::endl; + std::cout << std::format("6 : {:%H時%M分%S秒}", now_sec) << std::endl; + std::cout << std::format("7 : {:%T}", now_sec) << std::endl; } ``` * chrono::gps_clock[link gps_clock.md] @@ -193,9 +196,9 @@ int main() * chrono::floor[link time_point/floor.md] * std::format[link format.md] -#### 出力例 +#### 出力 ``` -1 : 2019-12-20 10:05:05 GPS +1 : 2019-12-20 10:05:05 2 : 2019年12月20日 10時05分05秒 3 : 2019/12/20 10:05:05 GPS 4 : 2019年12月20日 @@ -204,13 +207,14 @@ int main() 7 : 10:05:05 ``` + ## バージョン ### 言語 - C++20 ### 処理系 - [Clang](/implementation.md#clang): 9.0 [mark noimpl] -- [GCC](/implementation.md#gcc): 9.2 [mark noimpl] +- [GCC](/implementation.md#gcc): 9.2 [mark noimpl], 14.1 [mark verified] - [Visual C++](/implementation.md#visual_cpp): 2019 Update 3 [mark noimpl]