11---
22description : " Learn more about: <chrono> operators"
33title : " <chrono> operators"
4- ms.date : " 08/13 /2021"
5- f1_keywords: ["chrono/std::operator modulo", "chrono/std::operator+", "chrono/std::chrono::day::operator+", "chrono/std::chrono::duration::operator+", "chrono/std::chrono::month::operator+", "chrono/std::chrono::time_point::operator+", "chrono/std::chrono::weekday::operator+", "chrono/std::chrono::year_month::operator+", "chrono/std::chrono::year::operator+", "chrono/std::chrono::year_month_day::operator+", "chrono/std::chrono::year_month_day_last::operator+", "chrono/std::chrono::year_month_weekday::operator+", "chrono/std::chrono::year_month_weekday_last::operator+", "chrono/std::operator!=", "chrono/std::operator*", "chrono/std::operator/", "chrono/std::operator-", "chrono/std::operator<", "chrono/std::operator<=", "chrono/std::operator<", "chrono/std::operator==", "chrono/std::operator>>", "chrono/std::operator<=>", "chrono/std::chrono::day::operator<=>", "chrono/std::chrono::month::operator<=>", "chrono/std::chrono::year::operator<=>", "chrono/std::chrono::year_month::operator<=>", "chrono/std::chrono::time_point::operator<=>", "chrono/std::chrono::duration::operator<=>", "chrono/std::chrono::month_day_last::operator<=>", "chrono/std::chrono::year_month_day_last::operator<=>", "chrono/std::operator==", "chrono/std::chrono::year::operator<==>", "chrono/std::chrono::day::operator==", "chrono/std::chrono::duration::operator==", "chrono/std::chrono::month::operator==", "chrono/std::chrono::month_day::operator==", "chrono/std::chrono::month_day_last::operator==", "chrono/std::chrono::month_weekday::operator==", "chrono/std::chrono::month_weekday_last::operator==", "chrono/std::chrono::time_point::operator==", "chrono/std::chrono::weekday::operator==", "chrono/std::chrono::year_month::operator==", "chrono/std::chrono::year::operator==", "chrono/std::chrono::year_month_day::operator==", "chrono/std::chrono::year_month_day_last::operator==", "chrono/std::chrono::year_month_weekday_last::operator==", "chrono/std::chrono::year_month_weekday::operator==", "chrono/std::chrono::month_weekday_last::operator==", "chrono/std::chrono::weekday::operator==", "chrono/std::chrono::weekday_last::operator==", "chrono/std::chrono::year_month_weekday_indexed::operator==", "chrono/std::chrono::year_month_weekday_last::operator==", "chrono/std::chrono::year::operator==", "chrono/std::chrono::year_month::operator==", "chrono/std::chrono::year_month_day::operator==", "chrono/std::chrono::year_month_day_last::operator==", "chrono/std::operator-", "chrono/std::chrono::day::operator-", "chrono/std::chrono::duration::operator-", "chrono/std::chrono::month::operator-", "chrono/std::chrono::time_point::operator-", "chrono/std::chrono::weekday::operator-", "chrono/std::chrono::year_month::operator-", "chrono/std::chrono::year::operator-", "chrono/std::chrono::year_month_day::operator-", "chrono/std::chrono::year_month_day_last::operator-", "chrono/std::chrono::year_month_weekday::operator-", "chrono/std::chrono::year_month_weekday_last::operator-", "chrono/std::chrono::day::operator<<", "chrono/std::chrono::hh_mm_ss::operator<<", "chrono/std::chrono::month_day::operator<<", "chrono/std::chrono::month_day_last::operator<<", "chrono/std::chrono::month_weekday::operator<<", "chrono/std::chrono::month_weekday_last::operator<<", "chrono/std::chrono::weekday::operator<<", "chrono/std::chrono::weekday_indexed::operator<<", "chrono/std::chrono::weekday_last::operator<<", "chrono/std::chrono::year::operator<<", "chrono/std::chrono::year_month_day::operator<<", "chrono/std::chrono::year_month_day_last::operator<<", "chrono/std::chrono::year_month_weekday::operator<<", "chrono/std::chrono::utc_time::operator<<", "chrono/std::chrono::tai_time::operator<<", "chrono/std::chrono::gps_time::operator<<", "chrono/std::chrono::local_time::operator<<", "chrono/std::chrono::file_time::operator<<"]
4+ ms.date : 09/02 /2021
5+ f1_keywords: ["chrono/std::operator modulo", "chrono/std::operator+", "chrono/std::chrono::day::operator+", "chrono/std::chrono::duration::operator+", "chrono/std::chrono::month::operator+", "chrono/std::chrono::time_point::operator+", "chrono/std::chrono::weekday::operator+", "chrono/std::chrono::year_month::operator+", "chrono/std::chrono::year::operator+", "chrono/std::chrono::year_month_day::operator+", "chrono/std::chrono::year_month_day_last::operator+", "chrono/std::chrono::year_month_weekday::operator+", "chrono/std::chrono::year_month_weekday_last::operator+", "chrono/std::operator!=", "chrono/std::operator*", "chrono/std::operator/", "chrono/std::operator-", "chrono/std::operator<", "chrono/std::operator<=", "chrono/std::operator<", "chrono/std::operator==", "chrono/std::operator>>", "chrono/std::operator<=>", "chrono/std::chrono::day::operator<=>", "chrono/std::chrono::month::operator<=>", "chrono/std::chrono::year::operator<=>", "chrono/std::chrono::year_month::operator<=>", "chrono/std::chrono::time_point::operator<=>", "chrono/std::chrono::time_zone_link::operator<=>", "chrono/std::chrono::time_zone_link::operator==", "chrono/std::chrono::duration::operator<=>", "chrono/std::chrono::month_day_last::operator<=>", "chrono/std::chrono::year_month_day_last::operator<=>", "chrono/std::operator==", "chrono/std::chrono::year::operator<==>", "chrono/std::chrono::day::operator==", "chrono/std::chrono::duration::operator==", "chrono/std::chrono::month::operator==", "chrono/std::chrono::month_day::operator==", "chrono/std::chrono::month_day_last::operator==", "chrono/std::chrono::month_weekday::operator==", "chrono/std::chrono::month_weekday_last::operator==", "chrono/std::chrono::time_point::operator==", "chrono/std::chrono::weekday::operator==", "chrono/std::chrono::year_month::operator==", "chrono/std::chrono::year::operator==", "chrono/std::chrono::year_month_day::operator==", "chrono/std::chrono::year_month_day_last::operator==", "chrono/std::chrono::year_month_weekday_last::operator==", "chrono/std::chrono::year_month_weekday::operator==", "chrono/std::chrono::month_weekday_last::operator==", "chrono/std::chrono::weekday::operator==", "chrono/std::chrono::weekday_last::operator==", "chrono/std::chrono::year_month_weekday_indexed::operator==", "chrono/std::chrono::year_month_weekday_last::operator==", "chrono/std::chrono::year::operator==", "chrono/std::chrono::year_month::operator==", "chrono/std::chrono::year_month_day::operator==", "chrono/std::chrono::year_month_day_last::operator==", "chrono/std::operator-", "chrono/std::chrono::day::operator-", "chrono/std::chrono::duration::operator-", "chrono/std::chrono::month::operator-", "chrono/std::chrono::time_point::operator-", "chrono/std::chrono::weekday::operator-", "chrono/std::chrono::year_month::operator-", "chrono/std::chrono::year::operator-", "chrono/std::chrono::year_month_day::operator-", "chrono/std::chrono::year_month_day_last::operator-", "chrono/std::chrono::year_month_weekday::operator-", "chrono/std::chrono::year_month_weekday_last::operator-", "chrono/std::chrono::day::operator<<", "chrono/std::chrono::hh_mm_ss::operator<<", "chrono/std::chrono::month_day::operator<<", "chrono/std::chrono::month_day_last::operator<<", "chrono/std::chrono::month_weekday::operator<<", "chrono/std::chrono::month_weekday_last::operator<<", "chrono/std::chrono::weekday::operator<<", "chrono/std::chrono::weekday_indexed::operator<<", "chrono/std::chrono::weekday_last::operator<<", "chrono/std::chrono::year::operator<<", "chrono/std::chrono::year_month_day::operator<<", "chrono/std::chrono::year_month_day_last::operator<<", "chrono/std::chrono::year_month_weekday::operator<<", "chrono/std::chrono::utc_time::operator<<", "chrono/std::chrono::tai_time::operator<<", "chrono/std::chrono::gps_time::operator<<", "chrono/std::chrono::local_time::operator<<", "chrono/std::chrono::file_time::operator<<"]
66---
77# ` <chrono> ` operators
88
@@ -109,7 +109,7 @@ constexpr year_month_weekday_last operator+(const years& dy, const year_month_we
109109
1101104\) Returns the result of `d+ds.count()`. If the result is out of the range [0, 255], then the result is unspecified.
111111
112- 5\) Returns the result of `m+ms.count()`. If the result is out of the range [1, 12], it's reduced modulo 12 and then +1.
112+ 5\) Returns the result of `m+ms.count()`. If the result is out of the range [1, 12], it's reduced modulo 12 and then +1.
113113
1141146\) Returns the result of adding the number of days/weekdays to the `weekday`. The result will be modulo 7, so always in the range \[0,6]
115115
@@ -119,7 +119,7 @@ constexpr year_month_weekday_last operator+(const years& dy, const year_month_we
119119
1201209\) Returns the result of adding months or years to a `year_month_day`. If `ymd.month()` is `February` and `ymd.day()` is not in the range [1d, 28d], `ok()` may return `false` for the result of the addition.
121121
122- 10\) Returns `(ymdl.year() / ymdl.month() + dm) / last`. Note: The `/` used here is not a division operator but the date operator.
122+ 10\) Returns `(ymdl.year() / ymdl.month() + dm) / last`. Note: The `/` used here isn't a division operator but the date operator.
123123
12412411\) Returns `ymdl + dm`.
125125
@@ -129,7 +129,7 @@ constexpr year_month_weekday_last operator+(const years& dy, const year_month_we
129129
13013014-15\) Returns `{ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}`.
131131
132- 16\) Returns `(ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last()`. Note: The `/` used here is not a division operator but the date operator.
132+ 16\) Returns `(ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last()`. Note: The `/` used here isn't a division operator but the date operator.
133133
13413417\) Returns: `ymwdl + dy`
135135
@@ -307,9 +307,9 @@ constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl
307307
30830810\) Returns `years(int(y) - int(y2))`. Subtracting two `year` values results in a `std::chrono::years`, which represents the difference in years between `y` and `y2`. For example, `2021y-2000y` produces `years(21)`.
309309
310- 11\) Returns the result of subtracting a number of months or years from a `year_month` value.
310+ 11\) Returns the result of subtracting months or years from a `year_month` value.
311311
312- 12\) Returns the result of subtracting a number of months years from a `year_month_day` value.
312+ 12\) Returns the result of subtracting months years from a `year_month_day` value.
313313
31431413\) Returns the result of subtracting the number of months from the `year_month_day_last` value. Essentially: `ymdl-dm`.
315315
@@ -567,7 +567,8 @@ Determines whether:
56756714\) [ ` year_month_day ` ] ( year-month-day-class.md ) represent the same year, month, and day.\
56856815\) [ ` year_month_day_last ` ] ( year-month-day-last-class.md ) represent the same last day of the year and month.\
56956916\) [ ` year_month_weekday ` ] ( year-month-weekday-class.md ) represent the same weekday, year, and month.\
570- 17\) [ ` year_month_weekday_last ` ] ( year-month-weekday-last-class.md ) represent the same last weekday of the month, year, and month.
570+ 17\) [ ` year_month_weekday_last ` ] ( year-month-weekday-last-class.md ) represent the same last weekday of the month, year, and month.\
571+ 18\) [ ` time_zone_link ` ] ( time-zone-link-class.md ) have the same ` name ` . The ` target ` name isn't considered.
571572
572573``` cpp
573574// 1) duration<Rep, Period>
@@ -626,6 +627,9 @@ constexpr bool operator==(const year_month_weekday& Left, const year_month_weekd
626627
627628// 17) year_month_weekday_last
628629constexpr bool operator==(const year_month_weekday_last& Left, const year_month_weekday_last& Right) noexcept; // C++ 20
630+
631+ // 18) time_zone_link
632+ bool operator==(const time_zone_link& Left, const time_zone_link& Right) noexcept;
629633```
630634
631635### Parameters
@@ -638,9 +642,10 @@ The right object to compare.
638642
639643### Return value
640644
641- 1\) Returns **`true`** if *`Left`* and *`Right`* represent time intervals that have the same length. Otherwise, the function returns **`false`**.\
645+ 1\) Returns **`true`** if *`Left`* and *`Right`* represent time intervals that have the same length. Otherwise, returns **`false`**.\
6426462\) Returns **`true`** if *`Left`* and *`Right`* represent the same point in time. Otherwise, returns **`false`**.\
643- 3-17\) Returns **`true`** if *`Left`* and *`Right`* have the same value. Otherwise, returns **`false`**.
647+ 3-17\) Returns **`true`** if *`Left`* and *`Right`* have the same value. Otherwise, returns **`false`**.\
648+ 18\) Returns **`true`** if `Left.name() == Right.name()`. Otherwise, returns `*false*`.
644649
645650## <a name="op_gt"></a> `operator>`
646651
@@ -708,6 +713,7 @@ The spaceship operator, in conjunction with `operator==`, synthesizes operators
708713- [`month_day`](month-day-class.md)
709714- [`month_day_last`](month-day-last-class.md)
710715- [`time_point`](time-point-class.md)
716+ - [`time_zone_link`](time-zone-link-class.md)
711717- [`year`](year-class.md)
712718- [`year_month`](year-month-class.md)
713719- [`year_month_day_last`](year-month-day-last-class.md)
@@ -736,12 +742,15 @@ constexpr strong_ordering operator<=>(const month_day_last& Left, const month_da
736742
737743// 3)
738744constexpr strong_ordering operator<=>(const year_month_day_last& Left, const year_month_day_last& Right) noexcept;
745+
746+ //4)
747+ strong_ordering operator<=>(const time_zone_link& Left, const time_zone_link& Right) noexcept;
739748```
740749
741750### Parameters
742751
743752* ` Left ` , ` Right ` * \
744- The [ ` day ` ] ( day-class.md ) , [ ` duration ` ] ( duration-class.md ) , [ ` month ` ] ( month-class.md ) , [ ` month_day ` ] ( month-day-class.md ) , [ ` month_day_last ` ] ( month-day-last-class.md ) , [ ` time_point ` ] ( time-point-class.md ) , [ ` year ` ] ( year-class.md ) , [ ` year_month ` ] ( year-month-class.md ) , [ ` year_month_day ` ] ( year-month-day-class.md ) , [ ` year_month_day_last ` ] ( year-month-day-last-class.md ) to compare.
753+ The [ ` day ` ] ( day-class.md ) , [ ` duration ` ] ( duration-class.md ) , [ ` month ` ] ( month-class.md ) , [ ` month_day ` ] ( month-day-class.md ) , [ ` month_day_last ` ] ( month-day-last-class.md ) , [ ` time_point ` ] ( time-point-class.md ) , [ ` time_zone_link ` ] ( time-zone-link-class.md ) , [ ` year ` ] ( year-class.md ) , [ ` year_month ` ] ( year-month-class.md ) , [ ` year_month_day ` ] ( year-month-day-class.md ) , [ ` year_month_day_last ` ] ( year-month-day-last-class.md ) to compare.
745754
746755### Return value
747756
@@ -761,6 +770,12 @@ if (auto c = Left.year() <=> Right.year(); c != 0) return c;
761770return Left.month_day_last() <=> Right.month_day_last();
762771```
763772
773+ 4\) \
774+ Equivalent to:
775+ ``` cpp
776+ Left.name() <=> Right.name()
777+ ```
778+
764779### Example: ` operator<=> `
765780
766781``` cpp
0 commit comments