std::chrono...xed::weekday(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… NAME πŸ’…

std::chrono::weekday_indexed::weekday - std::chrono::weekday_indexed::weekday

okay bestie, welcome to the C++ Standard Libary manual page for std::chrono...xed::weekday(3) πŸ’– yes, we are literally here for the member function that hands you the weekday back out of a weekday_indexed. no cap.

✨ Synopsis ✨

constexpr std::chrono::weekday weekday() const noexcept;

since C++20 πŸ¦‹

It retrieves a copy of the std::chrono::weekday object stored in *this. that's the whole vibe. it's giving "tiny getter, main character energy" πŸ’…

🌸 Return value 🌸

A copy of the std::chrono::weekday object stored in *this. periodt. πŸŽ€

🧚 Example 🧚

// Run this code πŸ‘‡

#include <chrono>
#include <iostream>

int main()
{
    std::cout << std::boolalpha;

    // 2nd Tuesday of a month
    std::chrono::weekday_indexed wdi{std::chrono::Tuesday[2]};
    std::cout << (std::chrono::year_month_day{wdi/10/2019} ==
                  std::chrono::year_month_day{std::chrono::October/8/2019})
              << ' ';

    // 2nd Tuesday => 2nd Thursday
    wdi = {wdi.weekday() + std::chrono::days(2), wdi.index()};
    std::cout << (std::chrono::year_month_day{wdi/10/2019} ==
                  std::chrono::year_month_day{std::chrono::October/10/2019})
              << '\n';
}

Output:

true true

πŸ”₯ See also πŸ”₯

  • index β€” access the stored index (public member function) πŸ‘‘

xoxo, your C++ bestie πŸ’– β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::chrono...xed::weekday(3). byeeee πŸŽ€

πŸ“¦ where this page comes from