std::chrono::year_month_weekday:: year, std::chrono::year_month_weekday:: month, std::chrono::year_month_weekday:: weekday, std::chrono::year_month_weekday:: index, std::chrono::year_month_weekday:: weekday_indexed
From cppreference.net
<
cpp
|
chrono
|
year month weekday
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year_month_weekday
| Member functions | ||||
|
year_month_weekday::year
year_month_weekday::month
year_month_weekday::weekday
year_month_weekday::index
year_month_weekday::weekday_indexed
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
std::
chrono
::
year
year
(
)
const
noexcept
;
|
(1) | (C++20以降) |
|
constexpr
std::
chrono
::
month
month
(
)
const
noexcept
;
|
(2) | (C++20以降) |
|
constexpr
std::
chrono
::
weekday
weekday
(
)
const
noexcept
;
|
(3) | (C++20以降) |
|
constexpr
unsigned
index
(
)
const
noexcept
;
|
(4) | (C++20以降) |
|
constexpr
std::
chrono
::
weekday_indexed
weekday_indexed
(
)
const
noexcept
;
|
(5) | (C++20以降) |
この
year_month_weekday
オブジェクトに格納されているフィールド値を取得します。
戻り値
1)
格納されている
std::chrono::year
値を返します。
2)
格納された
std::chrono::month
値を返します。
3)
格納されている
std::chrono::weekday
値を返します。
4)
格納された曜日インデックスを返します。
5)
weekday
(
)
[
index
(
)
]
例
このコードを実行
#include <cassert> #include <chrono> int main() { constexpr auto ym{std::chrono::year(2021)/std::chrono::January}; constexpr auto wdi{std::chrono::Wednesday[1]}; auto ymwdi{ym/wdi}; const auto index{ymwdi.index() + 1}; auto weekday{ymwdi.weekday() + std::chrono::days(1)}; ymwdi = {ymwdi.year()/ymwdi.month()/weekday[index]}; // 2021年1月の第2木曜日 assert(std::chrono::year_month_day{ymwdi} == std::chrono::January/14/2021); }