std::chrono::year_month_weekday_last:: operator sys_days, std::chrono::year_month_weekday_last:: operator local_days
From cppreference.net
<
cpp
|
chrono
|
year month weekday last
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year_month_weekday_last
| Member functions | ||||
|
year_month_weekday_last::operator sys_days
year_month_weekday_last::operator local_days
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
operator
std::
chrono
::
sys_days
(
)
const
noexcept
;
|
(1) | (C++20 이후) |
|
constexpr
explicit
operator
std::
chrono
::
local_days
(
)
const
noexcept
;
|
(2) | (C++20 이후) |
*
this
를 이
year_month_weekday_last
와 동일한 날짜를 나타내는
std::chrono::time_point
로 변환합니다.
1)
만약
ok()
가
true
인 경우,
year()
와
month()
의 마지막
weekday()
를 나타내는
sys_days
를 반환합니다. 그렇지 않으면 반환 값은 지정되지 않습니다.
2)
(1)
과 동일하지만,
sys_days
대신
local_days
를 반환합니다.
local_days
(
sys_days
(
*
this
)
.
time_since_epoch
(
)
)
와 동등합니다.
예제
이 코드 실행
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto ymwdl{Tuesday[last]/11/2021}; static_assert(static_cast<local_days>(ymwdl) == static_cast<local_days>(November/30/2021)); // convert from field-based to serial-based to add days constexpr auto sd = static_cast<sys_days>(ymwdl); constexpr year_month_day ymd{sd + days(42)}; std::cout << ymd << '\n'; }
출력:
2022-01-11