year_month_day_last
year_month_day_last (연·월·마지막 날)
연도, 월, 그리고 "그 달의 마지막 날"을 조합한 날짜 타입이에요. <chrono> 헤더, C++20부터.
출처: cppreference
본문
std::chrono::year_month_day_last는 연·월과 그 달의 마지막 날을 나타내요.
class year_month_day_last;
year(),month(),day_last()멤버 제공.ok(): 연·월이 유효한지.operator/로 생성:2023y / February / last.
using namespace std::chrono;
auto mdl = 2023y / February / last; // 2023년 2월의 마지막 날
이 타입 자체는 "그 달의 마지막 날"이라는 의미만 담고, 실제 며칠인지는 year_month_day로 변환해 계산돼요. 예를 들어 2024년 2월 29일 같은 윤년 처리도 year_month_day_last -> year_month_day 변환이 정확히 해줘요.
월말 기준 날짜(예: 매월 말일) 연산을 표현할 때 유용해요.