Namensräume
Varianten
Aktionen

std::chrono::month_weekday::monat, std::chrono::month_weekday::weekday_indexed

Von cppreference.com
 
 
 
std::chrono::month_weekday
Memberfunktionen
month_weekday::monthmonth_weekday::weekday_indexed
Nicht-Member-Funktionen
Hilfsklassen
 
constexpr std::chrono::month month() const noexcept;
(1) (seit C++20)
constexpr std::chrono::weekday_indexed weekday_indexed() const noexcept;
(2) (seit C++20)

Ruft eine Kopie der in *this gespeicherten Objekte month und weekday_indexed ab.

[bearbeiten] Rückgabewert

1) Eine Kopie des in *this gespeicherten Objekts std::chrono::month.
2) Eine Kopie des in *this gespeicherten Objekts std::chrono::weekday_indexed.

[bearbeiten] Beispiel

#include <chrono>
#include <iostream>
 
int main()
{
    std::cout << std::boolalpha;
 
    auto mwdi{std::chrono::March/std::chrono::Friday[1]}; // 1st Friday in a March
    std::cout << (std::chrono::year_month_day{mwdi/2024} == 
                  std::chrono::year_month_day{std::chrono::March/1/2024})
                  << ' ';
    auto index = mwdi.weekday_indexed().index();
    auto weekday = mwdi.weekday_indexed().weekday();
    mwdi = {mwdi.month(), weekday[index + 4]}; // 5th Friday in a March
    std::cout << (std::chrono::year_month_day{mwdi/2024} == 
                  std::chrono::year_month_day{std::chrono::March/29/2024})
                  << '\n';
}

Ausgabe

true true