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

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

πŸ’– 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 πŸ’…

  1. Returns the stored std::chrono::year value. πŸ‘‘
  2. Returns the stored std::chrono::month value. 🌸
  3. A std::chrono::day value corresponding to the last day of the stored year and month. If this->ok() is false, the return value is unspecified. 🫠
  4. A std::chrono::month_day_last constructed from month(). πŸ’–
⚠️ 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