std::chrono::year_month_weekday:: operator sys_days, std::chrono::year_month_weekday:: operator local_days
From cppreference.net
<
cpp
|
chrono
|
year month weekday
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year_month_weekday
| Member functions | ||||
|
year_month_weekday::operator sys_days
year_month_weekday::operator local_days
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
operator
std::
chrono
::
sys_days
(
)
const
noexcept
;
|
(1) | (depuis C++20) |
|
constexpr
explicit
operator
std::
chrono
::
local_days
(
)
const
noexcept
;
|
(2) | (depuis C++20) |
Convertit
*
this
en un
std::chrono::time_point
représentant la même date que ce
year_month_weekday
.
1)
Si
year
(
)
.
ok
(
)
&&
month
(
)
.
ok
(
)
&&
weekday
(
)
.
ok
(
)
:
-
-
Si
index
(
)
==
0
, retourne un
sys_daysqui représente la date 7 jours avant le premierweekday()de l'année et du mois. -
Sinon, retourne un
sys_daysqui représente la date ( index ( ) - 1 ) * 7 jours après le premier weekday() de l'année et du mois.
-
Si
index
(
)
==
0
, retourne un
Sinon, la valeur retournée n'est pas spécifiée.
2)
Identique à
(1)
, mais retourne
local_days
au lieu de
sys_days
. Équivalent à
local_days
(
sys_days
(
*
this
)
.
time_since_epoch
(
)
)
.
Exemple
Exécuter ce code
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto ymwd{Tuesday[2]/11/2021}; std::cout << ymwd << '\n'; // convert from field-based to serial-based to add hours constexpr auto sd = sys_days{ymwd} + 24h; std::cout << sd << '\n'; constexpr auto ymd = floor<days>(sd); static_assert(ymd == November/10/2021); }
Sortie :
2021/Nov/Tue[2] 2021-11-10 00:00:00