std::chrono...last::month,(3)

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

✨ NAME ✨

Hi bestie πŸ’– welcome to std::chrono...last::month,(3) from the C++ Standard Libary β€” yes, that’s the manual name, typo and all, we keep it iconic.

The NAME line is exactly this chaotic cutie:

std::chrono::year_month_weekday_last::year,std::chrono::year_month_weekday_last::month, β€” std::chrono::year_month_weekday_last::year,std::chrono::year_month_weekday_last::month,

And the page itself covers accessors for year, month, weekday, and weekday_last, which you’ll see in the synopsis below. periodt ✨


🌸 Synopsis 🌸

First, the synopsis has this line chilling above everything:

std::chrono::year_month_weekday_last::weekday_last

Then the four signatures, all constexpr and noexcept, all since C++20:

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

(1) (since C++20)

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

(2) (since C++20)

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

(3) (since C++20)

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

(4) (since C++20)

The whole vibe here: it retrieves the field values stored in this year_month_weekday_last object. That’s literally the job. 🫢


πŸŽ€ Return value πŸŽ€

  1. Returns the stored std::chrono::year value. 🌈
  2. Returns the stored std::chrono::month value. 🌸
  3. Returns the stored std::chrono::weekday value. πŸ¦‹
  4. std::chrono::weekday_last(weekday()) πŸ’…

πŸ¦‹ Example πŸ¦‹

Run this code, bestie β€” the original literally says // Run this code, so go off:

#include <chrono>
#include <iostream>
using namespace std::chrono;

int main()
{
    auto ymwdl{Tuesday[last]/November/2022};
    auto wdl = ymwdl.weekday_last();
    wdl = (wdl.weekday() + days(1))[last];
    ymwdl = {ymwdl.year() + years(1), ymwdl.month() - months(2), wdl};
    std::cout << year_month_day(ymwdl) << '\n';
}

⭐ Output ⭐

2023-09-27

That’s the page, bestie πŸ’– source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::chrono...last::month,(3). Bye and slay your chrono builds πŸ’…βœ¨

πŸ“¦ where this page comes from