다음을 통해 공유


<chrono> 연산자

operator+

다음 형식에 대한 더하기 연산자:

1) 
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
   operator+(
      const duration<Rep1, Period1>& Left,
      const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
   operator+(
      const time_point<Clock, Duration1>& Time,
      const duration<Rep2, Period2>& Dur);

3)
template <class Rep1, class Period1, class Clock, class Duration2>
time_point<Clock, constexpr typename common_type<duration<Rep1, Period1>, Duration2>::type>
   operator+(
      const duration<Rep1, Period1>& Dur,
      const time_point<Clock, Duration2>& Time);

4)
constexpr day operator+(const day& d, const days& ds) noexcept; // C++20
constexpr day operator+(const days& ds, const day&  d) noexcept; // C++20

5)
constexpr month operator+(const month& m, const months& ms) noexcept; // C++20
constexpr month operator+(const months& ms, const month& m) noexcept; // C++20

6)
constexpr weekday operator+(const weekday& wd, const days& wds) noexcept // C++20
constexpr weekday operator+(const days& ds, const weekday& wd) noexcept; // C++20

7)
constexpr year operator+(const year& y, const years& ys) noexcept; // C++20
constexpr year operator+(const years& ys, const year& y) noexcept; // C++20

8)
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; // C++20
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; // C++20
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; // C++20
constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; // C++20

9)
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; // C++20
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; // C++20
constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; // C++20
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; // C++20

10)
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const months& dm) noexcept; // C++20

11)
constexpr year_month_day_last operator+(const months& dm, const year_month_day_last& ymdl) noexcept; // C++20

12)
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const years& dy) noexcept; // C++20
constexpr year_month_day_last operator+(const years& dy, const year_month_day_last& ymdl) noexcept; // C++20

13)
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const months& dm) noexcept; // C++20
constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) noexcept; // C++20

14)
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept; // C++20

15)
constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept; // C++20

16)
constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; // C++20
constexpr year_month_weekday_last operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; // C++20

17)
constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; // C++20
constexpr year_month_weekday_last operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; // C++20

반환 값

1) 변환한 LeftRight 후 공통 형식으로 변환된 duration 틱 개수의 합계와 같은 틱 수를 반환합니다.

2-3) 특정 시점의 간격 Dur 으로 변위되는 지정 시간을 Time나타내는 개체를 반환 time_point 합니다.

4) 의 결과를 반환합니다 d+ds.count(). 결과가 [0, 255] 범위를 벗어나면 결과가 지정되지 않습니다.

5) 의 결과를 반환합니다 m+ms.count(). 결과가 [1, 12] 범위를 벗어나면 모듈로 12와 +1이 줄어듭니다.

6) 일 수와 평일을 에 추가한 결과를 반환합니다 weekday. 결과는 모듈로 7이므로 항상 범위 [0,6]

7) 연도를 지정된 연도 수에 추가한 결과를 반환합니다.

8) 지정된 월 및 연도에 월 및 연도 수를 추가한 결과를 반환합니다.

9) 월 또는 연도 year_month_day를 에 추가한 결과를 반환합니다. ymd.day()February 범위 [1d, 28d] ok() 에 있지 않은 경우 ymd.month() 추가 결과를 반환 false 할 수 있습니다.

10) 반환합니다 (ymdl.year() / ymdl.month() + dm) / last. 참고: 여기서 사용되는 것은 / 나누기 연산자가 아닙니다. 날짜 연산자입니다.

11) 반환합니다 ymdl + dm.

12) 반환 {ymdl.year()+dy, ymdl.month_day_last()}

13) 반환합니다 ymwd + dm.count().

14-15) 반환합니다 {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}.

16) 반환합니다 (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last(). 참고: 여기서 사용되는 것은 / 나누기 연산자가 아니라 날짜 연산자입니다.

17) 반환: ymwdl + dy

예: operator+

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

using namespace std::chrono;

int main()
{
    // day
    day d{1};
    std::cout << d + days(2) << '\n'; // 03

    // month
    month m{11};
    std::cout << m + months(3)<< '\n'; // Feb

    // weekday
    weekday wd = Thursday;
    std::cout << wd + days(1) << '\n'; // Fri

    // year_month_day_last
    year_month_day_last ymdl{June / last / 2021};
    std::cout << ymdl + years{1} + months{1} << '\n'; // 2022/Jul/last

    // year_month_weekday
    year_month_weekday ymw{ year(1997) / January / Wednesday[1] };
    std::cout << ymw + months{1} << '\n'; // 1997/Feb/Wed[1]
    std::cout << ymw + years{1} << '\n'; // 1998/Jan/Wed[1] 

    // year_month_weekday_last
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl + months{ 1 } << '\n'; // 1997/Feb/Wed[last]
    std::cout << ymwl + years{ 1 } << '\n'; // 1998/Jan/Wed[last] 

    return 0;
}
03
Feb
Fri
2022/Jul/last
1997/Feb/Wed[1]
1998/Jan/Wed[1]
1997/Feb/Wed[last]
1998/Jan/Wed[last]

단항 operator+

다음 형식에 단항 더하기 적용:

// duration
constexpr common_type_t<duration> operator+() const // C++20

반환 값

*this를 반환합니다.

operator-

다음 형식에 대한 빼기 연산자:

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
   operator-(
       const duration<Rep1, Period1>& Left,
       const duration<Rep2, Period2>& Right);
2)
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type
   operator-(
       const time_point<Clock, Duration1>& Time,
       const duration<Rep2, Period2>& Dur);
3)
template <class Clock, class Duration1, class Duration2>
constexpr typename common_type<Duration1, Duration2>::type
   operator-(
       const time_point<Clock, Duration1>& Left,
       const time_point<Clock, Duration2>& Right);
4)
constexpr day operator-(const day& d,  days& ds) noexcept; // C++20
constexpr day operator-(const day& d, const day& d) noexcept; // C++20

5)
constexpr month operator-(const month& m, const months& ms) noexcept; // C++20
constexpr month operator-(const month& m, const month& ms) noexcept; // C++20

6)
constexpr months operator-(const year_month& Left, const year_month& Right) noexcept; // C++20

7)
constexpr weekday operator-(const weekday& Left, const days& Right) noexcept; // C++20

8)
constexpr days operator-(const weekday& Left, const weekday& Right) noexcept; // C++20

9)
constexpr year operator-(const year& y, const years& ys) noexcept; // C++20

10)
constexpr years operator-(const year& y, const year& y2) noexcept; // C++20

11)
constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; // C++20
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; // C++20

12)
constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; // C++20
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; // C++20

13)
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const months& dm) noexcept;  // C++20

14)
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const years& dy) noexcept;  // C++20

15)
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept; // C++20

16)
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept; // C++20

17)
constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; // C++20

18)
constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; // C++20

반환 값

1) 빼는 기간을 공통 형식으로 변환한 후 틱 수를 틱 수에서 뺀 틱 Right 수와 같은 값을 반환 duration 합니다Left.

2) 지정된 시점부터 나타내는 시간 간격Dur의 부정으로 인해 변위되는 시점Time을 나타내는 값을 반환 time_point 합니다.

3) 사이의 Left 시간 간격을 나타내는 개체를 반환 duration 합니다Right.

4) 의 결과를 반환합니다 d-ds.count(). 결과가 [0, 255] 범위를 벗어나면 결과가 지정되지 않습니다.

5) If m.ok() == truems.ok() == true, 두 달 값을 빼거나 월 수를 뺀 결과를 반환합니다. 결과는 [1, 12] 범위에 있습니다. 결과가 음수이면 래핑됩니다. 예를 들어 1월month m1{1} - months{1}; 에서 한 달을 빼면 12(12월)가 발생합니다.

6) 월의 Left 차이를 반환합니다. Right

7) If Left.ok() == trueRight.ok() == true, 범위의 [weekdaydays{0}, days{6}]를 반환합니다.

8) 평일 2일 사이의 일 수를 반환합니다.

9) 반환 year(int(y)-ys.count)())

10) 반환합니다 years(int(y) - int(y2)). 두 year 값을 std::chrono::years빼면 연도 간 y 차이를 나타내는 값이 생성됩니다 y2. 예를 들어 2021y-2000yyears(21)을 생성합니다.

11) 값에서 year_month 월 또는 연도를 빼는 결과를 반환합니다.

12) 값에서 year_month_day 월 연도를 뺀 결과를 반환합니다.

13) 값에서 year_month_day_last 월 수를 뺀 결과를 반환합니다. 본질적으로: ymdl-dm.

14) 값에서 year_month_day_last 연도 수를 뺀 결과를 반환합니다. 본질적으로: ymdl-dy.

15) 값에서 year_month_weekday 월 수를 뺀 결과를 반환합니다. 본질적으로: ymwd-dm.

16) 값에서 year_month_weekday 연도 수를 뺀 결과를 반환합니다. 본질적으로: ymwd-dy.

17) 값에서 year_month_weekday_last 월 수를 뺀 결과를 반환합니다. 본질적으로: ymwdl-dm.

18) 값에서 year_month_weekday_last 연도 수를 뺀 결과를 반환합니다. 본질적으로: ymwdl-dy.

예: operator-

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

using namespace std::chrono;

int main()
{
    // day
    day d{10};
    d = d - days(5);  
    std::cout << d << '\n'; // 05

    // month 
    month m{2};
    m = m - months{1};
    std::cout << m << '\n'; // Jan
    m = m - months{1};
    std::cout << m << '\n'; // Dec

    // year
    auto diff1 = 2021y-2000y;
    auto diff2 = 2021y-years{1};
    std::cout << diff1.count() << '\n'; // 21
    std::cout << diff2 << '\n'; // 2020

    // year_month
    const year theYear{ 2021 };
    year_month ym1{theYear, June};
    year_month ym2 = ym1 - months{2};
    std::cout << ym2 << '\n'; // 2021/Apr
    year_month ym3 = ym1 - years{2};
    std::cout << ym3 << '\n'; // 2019/Jun

    // year_month_day_last
    year_month_day_last ymdl = June / last / 2021;
    std::cout << ymdl - years{1} - months{1} << '\n'; // 2022/Jul/last

    // year_month_weekday
    year_month_weekday ymw{ year(1997) / January / Wednesday[1] };
    std::cout << ymw - months{1} << '\n'; // 1996/Dec/Wed[1]
    std::cout << ymw - years{1} << '\n'; // 1996/Jan/Wed[1] 

    // year_month_weekday_last
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl - months{ 1 } << '\n'; // 1996/Dec/Wed[last]
    std::cout << ymwl - years{ 1 } << '\n'; // 1996/Jan/Wed[last]
    
    return 0;
}
05
Jan
Dec
21
2020
2021/Apr
2019/Jun
2020/May/last
1996/Dec/Wed[1]
1996/Jan/Wed[1]
1996/Dec/Wed[last]
1996/Jan/Wed[last]

단항 operator-

를 부정합니다 duration.

constexpr common_type_t<duration> operator-() const;

반환 값

의 부정된 복사본을 반환합니다. *this

예: 단항 operator-

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

using namespace std::chrono;

int main()
{
   duration<int, std::milli> milliseconds(120);
   std::cout << -milliseconds << '\n';
   return 0;
}
-120ms

operator!=

다음 여부를 결정합니다.

1) 두 duration 개체가 같은 수의 틱을 나타내지 않습니다.
2) 두 time_point 개체가 같은 시점을 나타내지 않습니다.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator!=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator!=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

매개 변수

Left
왼쪽 duration 또는 time_point 개체입니다.

Right
오른쪽 duration 또는 time_point 개체입니다.

반환 값

1) true 일반적인 LeftRight 형식의 틱 수가 같지 않은지 반환합니다. 그렇지 않으면 false을(를) 반환합니다.
2) truetime_point 개체가 같은 시점을 나타내지 않는 경우 반환합니다. 그렇지 않으면 false을(를) 반환합니다.

operator*

duration 개체에 대한 곱하기 연산자입니다. 공통 형식으로 duration곱한 s를 변환한 후 변환된 틱 개수의 곱하기와 같은 틱 수를 반환 duration 합니다.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period1>
   operator*(
      const duration<Rep1, Period1>& Dur,
      const Rep2& Mult);

2)
template <class Rep1, class Rep2, class Period2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period2>
   operator*(
       const Rep1& Mult,
       const duration<Rep2,
       Period2>& Dur);

매개 변수

Dur
duration 개체입니다.

Mult
정수 값입니다.

반환 값

duration 간격 길이 Mult 에 길이를 곱한 개체를 Dur반환합니다.

1) 보유true하지 않는 한 is_convertible<Rep2, common_type<Rep1, Rep2>>이 함수는 오버로드 확인에 참여하지 않습니다. 자세한 내용은 type_traits> 참조<하세요.

2) 보유true하지 않는 한 is_convertible<Rep1, common_type<Rep1, Rep2>>이 함수는 오버로드 확인에 참여하지 않습니다. 자세한 내용은 type_traits> 참조<하세요.

operator<

1) 공통 형식과 비교되는 s를 변환 duration한 후 틱 수가 에 대한 Left 것보다 Right적은지 확인합니다.

2) epoch 이후의 시점이 in의 Lefttime_point epoch time_pointRight이후 시간보다 작은지 여부를 결정합니다.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator<(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator<(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

매개 변수

Left
왼쪽 duration 또는 time_point 개체입니다.

Right
오른쪽 duration 또는 time_point 개체입니다.

반환 값

1) 틱 수가 틱 Left 수보다 작은 경우 반환 true 합니다Right. 그렇지 않으면 false를 반환합니다.

2) 앞에 오는 경우 Left 반환 true 합니다Right. 그렇지 않으면 false을(를) 반환합니다.

operator<=

1) 공통 형식과 duration비교되는 s를 변환한 후 틱 수가 더 적거나 같은Right지 확인합니다Left.

2) epoch 이후의 시점이 in의 Lefttime_point epoch time_pointRight이후의 시간보다 작거나 같은지 여부를 결정합니다.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator<=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator<=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

매개 변수

Left
왼쪽 duration 또는 time_point 개체입니다.

Right
오른쪽 duration 또는 time_point 개체입니다.

반환 값

1) 틱 수가 틱 Left 수보다 작거나 같은지 여부를 반환 true 합니다Right. 그렇지 않으면 false를 반환합니다.

2) 앞에 오거나 같은 경우 Left 를 반환 true 합니다Right. 그렇지 않으면 false을(를) 반환합니다.

operator==

다음 여부를 결정합니다.

1) duration 개체는 길이가 같은 시간 간격을 나타냅니다.
2) time_point 개체는 동일한 시점을 나타냅니다.
3) day 개체는 같은 날을 나타냅니다.
4) month 개체는 같은 달을 나타냅니다.
5) month_day 개체는 같은 달과 요일을 나타냅니다.
6) month_day_last 개체는 같은 달을 나타냅니다.
7) month_weekday 개체는 같은 달과 n번째 평일을 나타냅니다.
8) month_weekday_last 개체는 같은 달과 지난 평일을 나타냅니다.
9) weekday 개체는 같은 평일을 나타냅니다.
10) weekday_last 개체는 해당 월의 마지막 요일을 나타냅니다.
11) weekday_indexed 같은 평일 인덱스입니다.
12) year 같은 연도를 나타냅니다.
13) year_month 같은 연도와 월을 나타냅니다.
14) year_month_day 같은 연도, 월 및 일을 나타냅니다.
15) year_month_day_last 연도 및 월의 마지막 날을 나타냅니다.
16) year_month_weekday 같은 평일, 연도 및 월을 나타냅니다.
17) year_month_weekday_last 월, 연도 및 월의 마지막 요일을 나타냅니다.
18) time_zone_link 동일한 name. 이름은 target 고려되지 않습니다.
19) zoned_time 동일한 시간과 표준 시간대를 나타냅니다.

// 1) duration<Rep, Period>
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator==(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

// 2) time_point
template <class Clock, class Duration1, class Duration2>
constexpr bool operator==(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

// 3) day
constexpr bool operator==(const day& Left, const day& Right) noexcept; // C++20

// 4) month
constexpr bool operator==(const month& Left, const month& Right) noexcept; // C++20

// 5) month_day
constexpr bool operator==(const month_day& Left, const month_day& Right) noexcept; // C++20

// 6) month_day_last
constexpr bool operator==(const month_day_last& Left, const month_day_last& Right) noexcept; // C++20

// 7) month_weekday
constexpr bool operator==(const month_weekday& Left, const month_weekday& Right) noexcept; // C++20

// 8) month_weekday_last
constexpr bool operator==(const month_weekday_last& Left, const month_weekday_last& Right) noexcept; // C++20

// 9) weekday
constexpr bool operator==(const weekday& Left, const weekday& Right) noexcept; // C++20

// 10) weekday_last
constexpr bool operator==(const weekday_last& Left, const weekday_last& Right) noexcept; // C++20

// 11) weekday_indexed
constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; // C++20

// 12) year
constexpr bool operator==(const year& Left, const year& y ) noexcept; // C++20

// 13) year_month
constexpr bool operator==(const year_month& Left, const year_month& Right) noexcept; // C++20

// 14) year_month_day
constexpr bool operator==(const year_month_day& Left, const year_month_day& Right) noexcept; // C++20

// 15) year_month_day_last
constexpr bool operator==(const year_month_day_last& Left, const year_month_day_last& Right) noexcept; // C++20

// 16) year_month_weekday
constexpr bool operator==(const year_month_weekday& Left, const year_month_weekday& Right) noexcept; // C++20

// 17)  year_month_weekday_last
constexpr bool operator==(const year_month_weekday_last& Left, const year_month_weekday_last& Right) noexcept; // C++20

// 18) time_zone_link
bool operator==(const time_zone_link& Left, const time_zone_link& Right) noexcept; // C++20

// 19) zoned_time
template <class Duration1, class Duration2, class TimeZonePtr>
bool operator==(const zoned_time<Duration1, TimeZonePtr>& Left, const zoned_time<Duration2, TimeZonePtr>& Right); // C++20

매개 변수

Left
비교할 왼쪽 개체(예: Left == Right

Right
비교할 오른쪽 개체입니다.

반환 값

1) true 형식의 틱 수가 공통 Left 이고 Right 같은지 반환합니다. 그렇지 않으면 false을(를) 반환합니다.
2) 동일한 시점을 나타내는 경우 Left 를 반환 true 합니다Right. 그렇지 않으면 false을(를) 반환합니다.
3-17) 값이 같으면 LeftRight 반환 true 합니다. 그렇지 않으면 false을(를) 반환합니다.
18) 반환 true 합니다.Left.name() == Right.name() 그렇지 않으면 *false*을(를) 반환합니다.
19) 반환 true 하는 경우 Left.get_time_zone() == _Right.get_time_zone() && Left.get_sys_time() == Right.get_sys_time();

operator>

1) 공통 형식과 duration비교되는 s를 변환한 후 틱 수가 틱 수보다 Right큰지 확인합니다Left.

2) epoch 이후의 시점이 in의 Lefttime_point epoch time_pointRight이후의 시간보다 큰지 여부를 결정합니다.

1) 
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator>(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator>(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

매개 변수

Left
왼쪽 duration 또는 time_point 개체입니다.

Right
오른쪽 duration 또는 time_point 개체입니다.

반환 값

1) 틱 수가 틱 Left 수보다 큰 경우 반환 true 합니다Right. 그렇지 않으면 false를 반환합니다.

2) 다음이 오는 Right경우 Left 반환합니다true. 그렇지 않으면 false을(를) 반환합니다.

operator>=

1) 공통 형식과 duration비교되는 s를 변환한 후 틱 수가 틱 수보다 크거나 같은Right지 확인합니다Left.

2) epoch 이후의 시점이 in의 Lefttime_point epoch time_pointRight이후의 시간보다 크거나 같은지 여부를 결정합니다.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator>=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator>=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

매개 변수

Left
왼쪽 duration 또는 time_point 개체입니다.

Right
오른쪽 duration 또는 time_point 개체입니다.

반환 값

1) 틱 수가 틱 Left 수보다 크거나 같은지 여부를 반환 true 합니다Right. 그렇지 않으면 false를 반환합니다.

2) 다음에 오거나 같은 Right경우 Left 반환 true 합니다. 그렇지 않으면 false을(를) 반환합니다.

operator<=>

우주선 연산자는 , operator==, 및 다음 형식에 대한 !=<<=>>=연산자를 합성합니다.

1)
constexpr bool operator<=>(const day& Left, const day& Right) noexcept; // C++20

constexpr std::strong_ordering operator<=>(const month& Left, const month& Right) noexcept; // C++20

constexpr strong_ordering operator<=>(const month_day& Left, const month_day& Right) noexcept; // C++20

constexpr std::strong_ordering operator<=>(const year& Left, const year& Right ) noexcept; // C++20

constexpr strong_ordering operator<=>(const year_month& Left, const year_month& Right) noexcept; // C++20

template<class Clock, class Duration1, three_­way_­comparable_­with<Duration1> Duration2>
    constexpr auto operator<=>(const time_point<Clock, Duration1>& Left, const time_point<Clock, Duration2>& Right); // C++20

template<class Rep1, class Period1, class Rep2, class Period2>
  requires three_­way_­comparable<typename CT::rep>
    constexpr auto operator<=>(const duration<Rep1, Period1>& Left, const duration<Rep2, Period2>& Right);

2)
constexpr strong_ordering operator<=>(const month_day_last& Left, const month_day_last& Right) noexcept;

3)
constexpr strong_ordering operator<=>(const year_month_day_last& Left, const year_month_day_last& Right) noexcept;

4)
strong_ordering operator<=>(const time_zone_link& Left, const time_zone_link& Right) noexcept;

매개 변수

Left, Right
day비교할 , duration,month, month_day, month_day_lasttime_point, time_zone_linkyear, year_month, , year_month_dayyear_month_day_last

반환 값

1)
0 경우 Left == Right
< 0 경우 Left < Right
> 0 경우 Left > Right

2)
해당 항목: Left.month() <=> Right.month()

3)
해당 항목:

if (auto c = Left.year() <=> Right.year(); c != 0) return c;
return Left.month_day_last() <=> Right.month_day_last();

4)
해당 항목:

Left.name() <=> Right.name()

예: operator<=>

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

using namespace std::chrono; // for day and 'd' literals

int main()
{
    day d1{3};
    day d2{2};

    if ((d1 <=> d2) == 0)
    {
        std::cout << "equal\n";
    }
    else if ((d1 <=> d2) < 0)
    {
        std::cout << "d1 < d2\n";
    }
    else if ((d1 <=> d2) > 0)
    {
        std::cout << "d1 > d2\n";
    }

    std::cout << std::boolalpha << (1d <= 1d) << ' ' << (1d != 2d) << ' ' << (2d > 3d);

    return 0;
}
d1 < d2
true true false 

operator<<

스트림에 다음 형식을 출력합니다.

// 1) day
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const day& d); // C++20

// 2) hh_mm_ss
template<class CharT, class traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const hh_mm_ss<Duration>& hms); // C++20

// 3) month
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month& m); // C++20

// 4) month_day
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_day& md); // C++20

// 5) month_day_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_day_last& mdl); // C++20

// 6) month_weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_weekday& mwd); // C++20

// 7) month_weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl); // C++20

// 8) weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday& wd); // C++20

// 9) weekday_indexed
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi); // C++20

// 10) weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday_last& wdl); // C++20

// 11) year
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year& y); // C++20

// 12) year_month
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month& ym); // C++20

// 13) year_month_day
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_day& ymd); // C++20

// 14) year_month_day_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl); // C++20

// 15) year_month_weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwd); // C++20

// 16) year_month_weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl); // C++20

// 17) tai_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const tai_time<Duration>& t); // C++20

// 18) utc_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, traits>&
operator<<(basic_ostream<CharT, Traits>& os, const utc_time<Duration>& t); // C++20

// 19) gps_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const gps_time<Duration>& t); // C++20

// 20) local_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const local_time<Duration>& t); // C++20

// 21) sys_info
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const sys_info& si);

// 22) local_info
template<class CharT, class Traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<CharT, Traits>& os, const local_info& li);

// 23) zoned_time
template<class CharT, class Traits, class Duration, class TimeZonePtr>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const zoned_time<Duration, TimeZonePtr>& zt);

매개 변수

CharT
스트림에서 읽고 문자열에 저장할 단일 문자의 데이터 형식입니다. C++ 표준 라이브러리는 형식 요소, , for, for 및 for에 대한 형식 wstringchar32_tcharu32stringwchar_tchar16_tu16string 정의 string 와 함께 이 클래스 템플릿의 특수화를 제공합니다.

Traits
CharT 특수화 및 basic_istream 특성에 basic_string 대해 설명합니다.

os
값을 내보 day 낸 출력 스트림입니다.

d
day 출력할 수 있습니다.

hms
hh_mm_ss 출력할 수 있습니다.

li
local_info 출력할 수 있습니다.

m
month 출력할 수 있습니다.

md
month_day 출력할 수 있습니다.

mdl
month_day_last 출력할 수 있습니다.

mwd
month_weekday 출력할 수 있습니다.

mwdl
month_weekday_last 출력할 수 있습니다.

si
sys_info 출력할 수 있습니다.

t
local_time, gps_time또는 tai_timeutc_time 출력입니다.

TimeZonePtr
저장된 time_zone 대한 포인터입니다 zoned_time.

wd
weekday 출력할 수 있습니다.

wdi
weekday_indexed 출력할 수 있습니다.

wdl
weekday_last 출력할 수 있습니다.

y
year 출력할 수 있습니다.

ym
year_month 출력할 수 있습니다.

ymd
year_month_day 출력할 수 있습니다.

ymdl
year_month_day_last 출력할 수 있습니다.

ymwd
year_month_weekday 출력할 수 있습니다.

ymwdl
year_month_weekday_last 출력할 수 있습니다.

zt
zoned_time 출력할 수 있습니다.

반환 값

전달한 출력 스트림 os

설명

1) 값은 day 10진수로 출력되며 결과가 한 자리이면 선행 0입니다. 이면 !d.ok()출력에 "유효한 날짜가 아닙니다"가 추가됩니다.

2) 값은 hh_mm_ss 시간:분:초:천분의 초로 출력됩니다. 예를 들면 "입니다 "00:00:05.721.

3) 연결된 os로캘을 사용하는 약어 월 이름이 출력됩니다. 예들 들어 Jan입니다. " is not a valid month" 이면 !m.ok()출력에 추가됩니다.

4) 연결된 os로캘을 사용한 약식 월 이름 뒤에 날짜가 표시되고 결과가 한 자리이면 앞에 오는 0이 출력됩니다. 예들 들어 Jan/05입니다. " is not a valid month" 이면 !md.ok()월의 출력에 추가될 수 있으며 "is not a valid day" 해당 날짜의 출력에 추가될 수 있습니다. 예들 들어 204 is not a valid month/204 is not a valid day입니다.

5) 다음에 os연결된 /last로캘을 사용하는 약식 월 이름입니다. 예들 들어 Jan/last입니다.

6) 연결된 os로캘을 사용하는 약식 평일 이름이며, 그 다음 달에 n번째 평일이 대괄호로 표시됩니다. 예들 들어 Mon[1]입니다.

7) 연결된 os로캘을 사용하는 약식 평일 이름이며, 그 다음에는 대괄호로 표시된 월의 마지막 요일이 뒤따릅니다. 예들 들어 Jan/Mon[last]입니다.

8) 연결된 os로캘을 사용하는 약식 평일 이름이 출력됩니다. " is not a valid weekday" 이면 !wd.ok()출력에 추가됩니다.

9) 연결된 os로캘을 사용하는 약식 평일 이름은 출력되고, 그 다음에는 월의 평일이 대괄호로 표시됩니다. 예들 들어 Mon[3]입니다. " is not a valid weekday" 이면 !wd.ok()요일 출력에 추가될 수 있으며 "is not a valid index" 평일 인덱스 출력에 추가될 수 있습니다.

10) 연결된 os로캘을 사용하는 월의 마지막 요일은 출력이고 그 뒤에 [last]날짜가 잇습니다. 예들 들어 Tue[last] 2019-10-29입니다. " is not a valid weekday" 이면 !wd.ok()요일 출력에 추가될 수 있으며 "is not a valid index" 평일 인덱스 출력에 추가될 수 있습니다.

11) 결과가 그보다 작을 경우 연도는 0에서 4 자리까지 왼쪽 패딩됩니다. " is not a valid year" 이면 !y.ok()출력에 추가됩니다.

12) year_month yyy-mm-dd 형식의 출력입니다. 반환 false" is not a valid date" 되는 경우 ym.ok 추가됩니다.

13) year_month_day yyyy-mm-dd 형식의 출력입니다. 반환 false" is not a valid date" 되는 경우 ymd.ok 추가됩니다.

14) year_month_day_last yyyy/month/last 형식의 출력입니다. 예들 들어 2020/May/last입니다.

15) year_month_weekday yyyy/month/weekday[index] 형식의 출력입니다. 예를 들어 1996/Jan/Wed[1]

16) year_month_weekday_last yyyy/month/weekday[last]형식의 출력입니다. 예를 들어 1996/Jan/Wed[last]

17) tai_time yyyy-mm-dd hh:mm:ss.sss 형식의 출력입니다. 예를 들어 2021-08-13 23:23:08.4358666

18) utc_time yyyy-mm-dd hh:mm:ss.sss 형식의 출력입니다. 예를 들어 2021-08-13 23:23:08.4358666

19) gps_time yyyy-mm-dd hh:mm:ss.sss 형식의 출력입니다. 예를 들어 2021-08-13 23:23:08.4358666

20) 시계 local_time 의 epoch 이후의 시간(초)으로 출력됩니다. 마치 다음과 같은 os << std::chrono::sys_time<Duration>(some_local_time.time_since_epoch());출력입니다. 예를 들어 2021년 8월 18일 오후 3시 13분인 경우 some_local_time 출력은 다음과 같습니다 1597792380.

21) Microsoft의 구현에서 a sys_info 는 해당begin, end, offsetsaveabbrev 필드로 출력됩니다. 예: begin: 2021-03-14 10:00:00, end: 2021-11-07 09:00:00, offset: -25200s, save: 60min, abbrev: PDT

22) Microsoft의 구현에서 a local_info 는 yyyy-mm-dd hh:mm::ss.sssss로 출력됩니다. 예를 들어 2021-09-17 13:55:59.6590120

23) (로 획득zt.get_local_time())의 zoned_time 현지 시간은 yyyy-mm-dd hh:mm:ss 표준 시간대 형식을 사용하여 출력됩니다. 예를 들어 2021-09-15 10:45:00 GMT-6

예: operator<<

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

using namespace std::chrono;

int main()
{
    std::cout << utc_clock::now() << '\n';

    year_month ym{ 2021y / April };
    std::cout << ym;
    return 0;
}
2021-08-16 20:47:05.6299822
2021/Apr

operator modulo

에 대한 모듈로 연산자 duration입니다.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<Rep1, Period1, Rep2>::type
   operator%(
      const duration<Rep1, Period1>& Dur,
      const Rep2& Div);

2)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, _Period1>, duration<Rep2, Period2>>::type
   operator%(
     const duration<Rep1, Period1>& Left,
     const duration<Rep2, Period2>& Right);

매개 변수

Dur
duration 개체입니다.

Div
정수 값입니다.

Left
피제수입니다. 모듈로는 배당을 수수로 나눈 후 re기본der입니다.

Right
오른쪽 duration 개체인 수수입니다.

반환 값

1) 간격 길이가 duration 모듈로DivDur 개체를 반환합니다.

2) 모듈로Right를 나타내는 값을 반환합니다Left.

duration의 경우 operator/

duration 개체에 대한 나누기 연산자입니다.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period1>
   operator/(
     const duration<Rep1, Period1>& Dur,
     const Rep2& Div);

2)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<Rep1, Rep2>::type
   operator/(
     const duration<Rep1, Period1>& Left,
     const duration<Rep2, Period2>& Right);

매개 변수

Dur
duration 개체입니다.

Div
정수 값입니다.

Left\w 왼쪽 duration 개체입니다.

Right
오른쪽 duration 개체입니다.

반환 값

1) 간격 길이가 값Div으로 나눈 길이인 Dur 기간 개체입니다.

2) 간격 길이 LeftRight.

trueRep2 유지하고 인스턴스화duration가 아닌 경우 is_convertible<Rep2, common_type<Rep1, Rep2>>첫 번째 연산자는 오버로드 확인에 참여하지 않습니다. 자세한 내용은 type_traits> 참조<하세요.

operator/ 일정 날짜

다음 형식으로 달력 날짜를 만드는 구문을 제공합니다.

월/일/연도
day/month/year
연도/월/일

다음으로 일을 바꿀 수 있습니다.

last
weekday[n] 월의 n번째 날
weekday[last] 월의 마지막 weekday 에 대한 입니다.

부분 날짜는 다음과 같이 구성할 수 있습니다.

year_month ym = 2015y/April;
month_day md1 = April/4;
month_day md2 = 4d/April;

해석이 모호하지 않은 한 정수는 사용할 수 있습니다.

/////////  returns year_month

// 1
constexpr year_month
operator/(const year& y, const month& m) noexcept; // C++20

// 2
constexpr year_month
operator/(const year& y, int m) noexcept; // C++20
 
/////////  returns month_day

// 3
constexpr month_day
operator/(const month& m, const day& d) noexcept; // C++20

// 4
constexpr month_day
operator/(const month& m, int d) noexcept; // C++20

// 5
constexpr month_day
operator/(int m, const day& d) noexcept; // C++20

// 6
constexpr month_day
operator/(const day& d, const month& m) noexcept; // C++20

// 7
constexpr month_day
operator/(const day& d, int m) noexcept; // C++20

/////////  returns month_day_last

// 8
constexpr month_day_last
operator/(const month& m, last_spec) noexcept; // C++20

// 9
constexpr month_day_last
operator/(int m, last_spec) noexcept; // C++20

// 10
constexpr month_day_last
operator/(last_spec, const month& m) noexcept; // C++20

// 11
constexpr month_day_last
operator/(last_spec, int m) noexcept; // C++20

/////////  returns month_weekday

// 12
constexpr month_weekday
operator/(const month& m, const weekday_indexed& wdi) noexcept; // C++20

// 13
constexpr month_weekday
operator/(int m, const weekday_indexed& wdi) noexcept; // C++20

// 14
constexpr month_weekday
operator/(const weekday_indexed& wdi, const month& m) noexcept; // C++20

// 15
constexpr month_weekday
operator/(const weekday_indexed& wdi, int m) noexcept; // C++20

/////////  returns month_weekday_last

// 16
constexpr month_weekday_last
operator/(const month& m, const weekday_last& wdl) noexcept; // C++20

// 17
constexpr month_weekday_last
operator/(int m, const weekday_last& wdl) noexcept; // C++20

// 18
constexpr month_weekday_last
operator/(const weekday_last& wdl, const month& m) noexcept; // C++20

// 19
constexpr month_weekday_last
operator/(const weekday_last& wdl, int m) noexcept; // C++20

/////////  returns year_month_day

// 20
constexpr year_month_day
operator/(const year_month& ym, const day& d) noexcept; // C++20

// 21
constexpr year_month_day
operator/(const year_month& ym, int d) noexcept; // C++20

// 22
constexpr year_month_day
operator/(const year& y, const month_day& md) noexcept; // C++20

// 23
constexpr year_month_day
operator/(int y, const month_day& md) noexcept; // C++20

// 24
constexpr year_month_day
operator/(const month_day& md, const year& y) noexcept; // C++20

// 25
constexpr year_month_day
operator/(const month_day& md, int y) noexcept; // C++20

/////////  returns year_month_day_last

// 26
constexpr year_month_day_last
operator/(const year_month& ym, last_spec) noexcept; // C++20

// 27
constexpr year_month_day_last
operator/(const year& y, const month_day_last& mdl) noexcept; // C++20

// 28
constexpr year_month_day_last
operator/(int y, const month_day_last& mdl) noexcept; // C++20

// 29
constexpr year_month_day_last
operator/(const month_day_last& mdl, const year& y) noexcept; // C++20

// 30
constexpr year_month_day_last
operator/(const month_day_last& mdl, int y) noexcept; // C++20

/////////  returns year_month_weekday

// 31
constexpr year_month_weekday
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; // C++20

// 32
constexpr year_month_weekday
operator/(const year& y, const month_weekday& mwd) noexcept; // C++20

// 33
constexpr year_month_weekday
operator/(int y, const month_weekday& mwd) noexcept; // C++20

// 34
constexpr year_month_weekday
operator/(const month_weekday& mwd, const year& y) noexcept; // C++20

// 35
constexpr year_month_weekday
operator/(const month_weekday& mwd, int y) noexcept; // C++20

/////////  returns year_month_weekday_last

// 36
constexpr year_month_weekday_last
operator/(const year_month& ym, const weekday_last& wdl) noexcept; // C++20

// 37
constexpr year_month_weekday_last
operator/(const year& y, const month_weekday_last& mwdl) noexcept; // C++20

// 38
constexpr year_month_weekday_last
operator/(int y, const month_weekday_last& mwdl) noexcept; // C++20

// 39
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, const year& y) noexcept; // C++20

// 40
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, int y) noexcept; // C++20

매개 변수

d
그날. [1,31] 범위의 정수로 제공되거나 day.

lastspec
시퀀스의 마지막 항목을 나타내는 빈 태그 형식입니다. 예를 들어 2021y/May/last 2021년 5월의 마지막 날입니다.

m
월입니다. [1,12] 범위의 정수로 제공되거나 month.

md
월 및 일입니다.

mdl
지정된 월의 마지막 날입니다.

mwd
지정된 월의 n번째 평일입니다.

mwdl
지정된 월의 마지막 요일입니다.

wdi
평일 인덱스(weekday_indexed). 예를 들어 월 weekday_indexed(Monday, 1) 의 첫 번째 월요일입니다.

wdl
한 달의 마지막 평일입니다. 예를 들어 월 Monday[last] 의 마지막 월요일입니다.

y
연도 정수 또는 year으로 제공됩니다.

ym
연도 및 월입니다.

반환 값

1) year_month(y, m)
2) year_month(y, month(m))
3) month_day(m, d)
4) month_day(m, day(d))
5) month_day(month(m), d)
6) month_day(m, d)
7) month_day(month(m), d)
8) month_day_last(m)
9) month_day_last(month(m))
10) month_day_last(m)
11) month_day_last(month(m))
12) month_weekday(m, wdi)
13) month_weekday(month(m), wdi)
14) month_weekday(m, wdi)
15) month_weekday(month(m), wdi)
16) month_weekday_last(m, wdl)
17) month_weekday_last(month(m), wdl)
18) month_weekday_last(m, wdl)
19) month_weekday_last(month(m), wdl)
20) year_month_day(ym.year(), ym.month(), d)
21) year_month_day(ym.year(), ym.month(), day(d))
22) year_month_day(y, md.month(), md.day())
23) year_month_day(year(y), md.month(), md.day())
24) year_month_day(y, md.month(), md.day())
25) year_month_day(year(y), md.month(), md.day())
26) year_month_day_last(ym.year(), month_day_last(ym.month()))
27) year_month_day_last(y, mdl)
28) year_month_day_last(year(y), mdl)
29) year_month_day_last(y, mdl)
30) year_month_day_last(year(y), mdl)
31) year_month_weekday(ym.year(), ym.month(), wdi)
32) year_month_weekday(y, mwd.month(), mwd.weekday_indexed())
33) year_month_weekday(year(y), mwd.month(), mwd.weekday_indexed())
34) year_month_weekday(y, mwd.month(), mwd.weekday_indexed())
35) year_month_weekday(year(y), mwd.month(), mwd.weekday_indexed())
36) year_month_weekday_last(ym.year(), ym.month(), wdl)
37) year_month_weekday_last(y, mwdl.month(), mwdl.weekday_last())
38) year_month_weekday_last(year(y), mwdl.month(), mwdl.weekday_last())
39) year_month_weekday_last(y, mwdl.month(), mwdl.weekday_last())
40) year_month_weekday_last(year(y), mwdl.month(), mwdl.weekday_last())

예: operator/ 달력 날짜

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

using namespace std::chrono;

int main()
{
    month m{ July }; // Jul
    month_day md{ April / 4 }; // Apr/04
    month_day md2{ 4d / April }; // Apr/04
    month_day_last mdl{ January / last }; // Jan/last
    month_weekday mw{ 11 / Monday[1] }; // Nov/Mon[1]
    month_weekday_last mwl{ January / Monday[last] }; // Jan/Mon[last]
    weekday wd{ Monday }; // Mon
    weekday_indexed wdi{ Monday, 1 }; // Mon[1]
    year_month ym{ 2021y / April }; // 2021/Apr
    year_month_day ymd{ January / 1d / 2021y }; // 2021-01-01
    year_month_day ymd2{ 2021y / 5 / 7 }; // 2021-05-07
    year_month_day_last ymdl{ April / last / 1975 }; // 1975/Apr/last
    year_month_weekday ymw{ 1997y / January / Wednesday[1] }; // 1997/Jan/Wed[1]
    year_month_weekday_last ymwl{ 1997y / January / Wednesday[last] }; // 1997/Jan/Wed[last]
    int yearValue{ 2021 / 4 / 4 }; // 126

    std::cout << m << '\n' << md << '\n' << md2 << '\n' << mdl << '\n' << mw
        << '\n' << mwl << '\n' << wd << '\n' << wdi << '\n'
        << ym << '\n' << ymd << '\n' << ymd2 << '\n' << ymdl
        << '\n' << ymw << '\n' << ymwl << '\n' << yearValue;

    return 0;
}
Jul
Apr/04
Apr/04
Jan/last
Nov/Mon[1]
Jan/Mon[last]
Mon
Mon[1]
2021/Apr
2021-01-01
2021-05-07
1975/Apr/last
1997/Jan/Wed[1]
1997/Jan/Wed[last]
126