std::chrono...y::month_day(3)

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

🌈 std::chrono...y::month_day(3) 🌈

okay bestie, welcome to the C++ Standard Libary manual β€” yes, that spelling is in the header, don't come for me πŸ’€ β€” and today we're getting into std::chrono::month_day. it's giving calendar-core, it's giving constructor realness, and we're gonna keep every single detail bc that's the vibe ✨


πŸ’– NAME πŸ’–

std::chrono::month_day::month_day - std::chrono::month_day::month_day


✨ Synopsis ✨

          month_day() = default;                                     (1) (since
       C++20)
          constexpr month_day( const std::chrono::month& m,          (2) (since
       C++20)
                               const std::chrono::day& d ) noexcept;

Constructs a month_day. that's the whole assignment, and she ate πŸ’…

  • (1) β€” the default constructor. it leaves the stored month and day values uninitialized 😭. since C++20.
  • (2) β€” constructs a month_day that stores the month m and the day d. it's noexcept. since C++20.

πŸ“ Notes πŸ“

a more convenient way to construct a month_day is with operator/, e.g., std::chrono::April/1. like, that's literally the note, bestie 🫢


🌸 Example 🌸

        // Run this code

        #include <chrono>
        #include <iostream>

        int main()
        {
            using namespace std::chrono_literals;
            constexpr auto mo_da =
       std::chrono::month_day(std::chrono::February, 29d);
            std::cout << static_cast<unsigned>(mo_da.day()) << '/'
                      << static_cast<unsigned>(mo_da.month()) << '\n';
        }

πŸ“ Output πŸ“

        29/2

πŸ‘€ See also πŸ‘€

  • operator/ β€” conventional syntax for Gregorian calendar date creation (C++20) (function) πŸ”₯

okay that's the whole page, bestie 🫢 β€” huge thanks to http://cppreference.com, version 2024.06.10, for this std::chrono...y::month_day(3) page. mwah πŸ’‹

πŸ“¦ where this page comes from