다음을 통해 공유


year_month_weekday_last 클래스

특정 연도, 월 및 월의 마지막 요일입니다.

구문

class year_month_weekday_last; // C++20

설명

year_month_weekday_last 는 연중 및 월 지향 산술 연산을 지원하지만 일 지향 산술 연산은 지원하지 않습니다. 일 지향 산술 연산의 경우 변환을 사용하여 sys_days 일 지향 산술을 지원하는 변환으로 변환 sys_days합니다.

year_month_weekday_last는 일반적으로 복사할 수 표준 레이아웃 클래스 형식입니다.

멤버

속성 설명
Constructor 지정된 월 및 평일을 사용하여 a year_month_weekday_last 를 생성합니다.
month 월 값을 가져옵니다.
ok 유효한지 year_month_weekday_last 확인합니다.
operator+= 지정된 월 또는 연도 수를 추가합니다.
operator-= 지정한 월 또는 연도 수를 뺍니다.
operator local_days Epoch에서 system_clockyear_month_weekday_last 날짜까지의 일 수를 다음과 같이 local_days가져옵니다.
operator sys_days Epoch에서 system_clockyear_month_weekday_last 날짜까지의 일 수를 다음과 같이 sys_days가져옵니다.
weekday 평일을 가져옵니다.
weekday_last year_month_weekday_last위치에 저장된 값을 weekday_last 가져옵니다.
year 연도를 가져옵니다.

비멤버

이름 설명
operator+ 월 또는 연도를 추가합니다.
operator- 월 또는 연도를 뺍니다.
operator== year_month_weekday_last 값이 같은지 여부를 확인합니다.
operator<< 지정된 스트림에 출력 year_month_weekday_last 합니다.

요구 사항

헤더:<chrono> (C++20 이후)

네임스페이스:std::chrono

컴파일러 옵션:/std:c++latest

생성자

year_month_weekday_last를 생성합니다.

constexpr year_month_weekday_last(const year& y, const month& m, const weekday_last& wdl) noexcept

매개 변수

m
month 값입니다.

wdl
weekday_last 값입니다.

y
year 값입니다.

날짜를 지정하는 데 사용되는 C++20 구문에 대한 자세한 내용은 operator/

예: year_month_weekday_last 만들기

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ 1997y / January / Wednesday[last] };
    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]

month

월 값을 가져옵니다.

constexpr month month() const noexcept;

반환 값

month 값입니다.

ok

이 값에 저장된 값이 year_month_weekday_last 유효한지 확인합니다. 이 함수가 year반환true되려면 이 함수에 year_month_weekday_last 저장되는 ok <a0/&weekday_lasta0>입니다. 그렇지 않으면 false을(를) 반환합니다.

constexpr bool ok() const noexcept;

반환 값

true 값이 year_month_weekday_last 유효한 경우 그렇지 않으면 false입니다.
A year_month_weekday_last 는 ,이monthweekday_indexed면 유효하며 year 모두 유효합니다.

operator+=

year_month_weekday_last월 또는 연도를 추가합니다.

1) constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
2) constexpr year_month_weekday_last& operator+=(const years& y) noexcept;

매개 변수

m
추가할 월 수입니다.

y
추가할 연도 수입니다.

반환 값

*this 은 추가 결과를 반영합니다.

예: operator+=

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl << '\n';

    ymwl += months{ 1 };
    ymwl += years{ 1 };

    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]
1998/Feb/Wed[last]

operator-=

에서 year_month_weekday_last월 또는 연도를 뺍니다.

1) constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
2) constexpr year_month_weekday_last& operator-=(const years& y) noexcept;

매개 변수

m
뺄 월 수입니다.

y
뺄 연도 수입니다.

반환 값

*this 빼기의 결과를 반영합니다.

예: operator-=

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl << '\n';

    ymwl -= months{ 1 };
    ymwl -= years{ 1 };

    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]
1995/Dec/Wed[last]

operator local_days

Epoch(1/1/1/1970)에서 system_clock 다음 year_month_weekday_last 으로 일 수를 가져옵니다. local_days

constexpr explicit operator local_days() const noexcept;

반환 값

이면 ok()일 수를 .로 local_days{sys_days{*this}.time_since_epoch()}반환합니다. 그렇지 않으면 반환된 값이 지정되지 않습니다.

operator sys_days

Epoch(1/1/1/1970)에서 system_clockyear_month_daysys_days날짜까지의 일 수를 가져옵니다.

constexpr operator sys_days() const noexcept;

반환 값

이면 ok() == true마지막 weekday()year() / month() 나타내는 값을 반환 sys_days 합니다(참고: / 나누기는 아닌 날짜 연산자). 그렇지 않으면 반환된 값이 지정되지 않습니다.

weekday

를 가져옵니다 weekday.

constexpr weekday weekday() const noexcept;

반환 값

weekday.

weekday_last

year_month_weekday_last위치에 저장된 값을 weekday_last 가져옵니다.

constexpr weekday_indexed weekday_last() const noexcept;

반환 값

weekday_last.

year

연도 값을 가져옵니다.

constexpr year year() const noexcept;

반환 값

year 값입니다.

참고 항목

<chrono>
year
year_month
year_month_day
year_month_day_last
year_month_weekday
operator/
헤더 파일 참조