std::chrono::weekday_last:: weekday_last
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
weekday_last::weekday_last
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
(C++26)
|
|
constexpr
explicit
weekday_last
(
const
std::
chrono
::
weekday
&
wd
)
noexcept
;
|
(seit C++20) | |
Konstruiert ein
weekday_last
Objekt, das den
Wochentag
wd
speichert.
Hinweise
Eine bequemere Möglichkeit, einen
weekday_last
zu konstruieren, ist mit
weekday
s
operator
[
]
, d.h.
wd
[
std::
chrono
::
last
]
.
Beispiel
#include <chrono> #include <iostream> using namespace std::chrono; int main() { const year_month_day ymd{floor<days>(system_clock::now())}; const weekday_last wdl{Sunday[last]}; // A last Sunday of a month const year_month_day last_sun{ymd.year() / ymd.month() / wdl}; std::cout << "The last Sunday of current month falls on " << (int)last_sun.year() << '/' << (unsigned)last_sun.month() << '/' << (unsigned)last_sun.day() << '\n'; }
Mögliche Ausgabe:
The last Sunday of current month falls on 2021/9/26