std::chrono...last::month,(3)
π NAME π
hiii bestie π okay so this is the C++ Standard Libary manual page for std::chrono...last::month,(3). Yes, the manual name says Libary β typo and all, we keep it, details are sacred. The NAME line lists std::chrono::year_month_day_last::year and std::chrono::year_month_day_last::month, then a -, then std::chrono::year_month_day_last::year and std::chrono::year_month_day_last::month again. Double listing? iconic. no notes.
πΈ Synopsis πΈ
okay so here's the whole function lineup, 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::day day() const noexcept;
(3) (since C++20)
constexpr std::chrono::month_day_last month_day_last() const noexcept;
(4) (since C++20)
These retrieve the field values stored in this year_month_day_last object. stored fields, served fresh β¨
π Return value π
- Returns the stored
std::chrono::yearvalue. π - Returns the stored
std::chrono::monthvalue. πΈ - A
std::chrono::dayvalue corresponding to the last day of the stored year and month. Ifthis->ok()is false, the return value is unspecified. π« - A
std::chrono::month_day_lastconstructed frommonth(). π
β οΈ bestie, item 3 has the "unspecified" caveat: if this->ok() is false, the return value is unspecified. Do not act surprised when it is not helpful.
π Example π
kk run this code:
// Run this code
#include <chrono>
int main()
{
constexpr auto ymdl{std::chrono::last/11/2020};
static_assert
(
ymdl.day() == std::chrono::day(30) &&
ymdl.month() == std::chrono::November &&
ymdl.year() == std::chrono::year(2020) &&
ymdl.month_day_last() ==
std::chrono::November/std::chrono::last
);
}
obsessed with the static_assert doing a little vibe check on ymdl β day() against std::chrono::day(30), month() against std::chrono::November, year() against std::chrono::year(2020), and month_day_last() against std::chrono::November/std::chrono::last. slay β¨
source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::chrono...last::month,(3) β mwah, bye bestie ππ¦
π¦ 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