std::chrono...y::month_day(3)
π 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
monthanddayvalues uninitialized π. since C++20. - (2) β constructs a
month_daythat stores the monthmand the dayd. it'snoexcept. 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
- 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