std::chrono...orsys_days,(3)
okay bestie, welcome to the page for std::chrono...orsys_days,(3) from the C++ Standard Libary manual β¨ β yes, that spelling is exactly what's on the page, and we are keeping it, no cap π
.
π NAME π
the group-chat names for this one are literally:
std::chrono::year_month_weekday::operatorsys_days, -
std::chrono::year_month_weekday::operatorsys_days,
β¨ Synopsis β¨
here's the signature block, exactly as it appears:
constexpr operator std::chrono::sys_days() const noexcept;
(1) (since C++20)
constexpr explicit operator std::chrono::local_days() const
(2) (since C++20)
noexcept;
so the vibe is: this converts *this to a std::chrono::time_point representing the same date as this year_month_weekday π«Ά.
- if
year().ok() && month().ok() && weekday().ok():- if
index() == 0, it returns asys_daysthat represents the date7days prior to the firstweekday()of the year and month β. - else, it returns a
sys_daysthat represents the date(index() - 1) * 7days after the firstweekday()of the year and month. otherwise, the returned value is unspecified β that's the "do not count on it" vibe, bestie π« .
- if
- same as
(1), but returnslocal_daysinstead ofsys_days. equivalent tolocal_days(sys_days(*this).time_since_epoch()).
πΈ Example πΈ
run this code π
// Run this code
#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
constexpr auto ymwd{Tuesday[2]/11/2021};
std::cout << ymwd << '\n';
// convert from field-based to serial-based to add hours
constexpr auto sd = sys_days{ymwd} + 24h;
std::cout << sd << '\n';
constexpr auto ymd = floor<days>(sd);
static_assert(ymd == November/10/2021);
}
π Output π
2021/Nov/Tue[2]
2021-11-10 00:00:00
source/version/date sign-off, bestie: http://cppreference.com Β· 2024.06.10 Β· std::chrono...orsys_days,(3) β byeee, slay responsibly π
β¨
π¦ 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