std::chrono:: operator+, std::chrono:: operator- (std::chrono::year_month_day)
|
Definido en el encabezado
<chrono>
|
||
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(desde C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
months
&
dm,
const
std::
chrono
::
year_month_day
&
ymd
|
(desde C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(desde C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
years
&
dy,
const
std::
chrono
::
year_month_day
&
ymd
|
(desde C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(desde C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operador
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(desde C++20) | |
Para duraciones que son convertibles tanto a
std::chrono::years
como a
std::chrono::months
, las sobrecargas de
years
(3,4,6)
tienen preferencia si la llamada sería de otro modo ambigua.
Notas
Aún si
ymd.
ok
(
)
es
true
, el resultado
year_month_day
puede no representar una fecha válida si
ymd.
day
(
)
es 29, 30 o 31.
Ejemplo
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; auto ymd{std::chrono::day(1)/std::chrono::July/2021}; ymd = ymd + std::chrono::months(4); std::cout << (ymd.month() == std::chrono::November) << ' ' << (ymd.year() == std::chrono::year(2021)) << ' '; ymd = ymd - std::chrono::years(10); std::cout << (ymd.month() == std::chrono::month(11)) << ' ' << (ymd.year() == std::chrono::year(2011)) << '\n'; }
Salida:
true true true true