std::chrono...eekday_last(3)
π NAME π
Okay so this is a page from the C++ Standard Libary manual β yes, thatβs the manual name, folded in near the top like a little name tag β and the page tag is std::chrono...eekday_last(3).
The full NAME situation is std::chrono::month_weekday_last::month,std::chrono::month_weekday_last::weekday_last β both of those, together, no cap β and the description side of the dash is literally std::chrono::month_weekday_last::month,std::chrono::month_weekday_last::weekday_last. Periodt. π
πΈ Synopsis πΈ
These are the two member functions, and theyβre both constexpr plus noexcept, since C++20. Iconic behavior, honestly.
constexpr std::chrono::month month() const noexcept;
(1) (since C++20)
constexpr std::chrono::weekday_last weekday_last() const noexcept;
(2) (since C++20)
Both of these retrieve a copy of the month and weekday_last objects stored in *this. Thatβs the whole vibe. π¦
π Return value π
- A copy of the
std::chrono::monthobject stored in*this. - A copy of the
std::chrono::weekday_lastobject stored in*this.
π¦ Example π¦
Run this code, bestie β itβs giving βlast Friday agendaβ energy:
// Run this code
#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
std::cout << std::boolalpha;
auto mwdl{March/Friday[last]}; // Last Friday in a March
auto ywdl{year(2024)/mwdl};
std::cout << (year_month_day{ywdl} ==
year_month_day{March/29/2024}) << ' ';
// Last Friday of the next month, in 2024
mwdl = {(mwdl.month() + months(1))/mwdl.weekday_last()};
ywdl = {year(2024)/mwdl};
std::cout << (year_month_day{ywdl} ==
year_month_day{April/26/2024}) << '\n';
}
π Output π
true true
Sign-off tea β: source/version http://cppreference.com, date 2024.06.10, and page tag std::chrono...eekday_last(3). Bye bestie, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms