std::chrono...iso_encoding(3)
okay bestie, welcome to the std::chrono...iso_encoding(3) page from the C++ Standard Libary manual β yes, that's the manual name folded in right here so we don't copy the whole header line. β¨
π NAME π
std::chrono::weekday::c_encoding,std::chrono::weekday::iso_encodingβstd::chrono::weekday::c_encoding,std::chrono::weekday::iso_encoding
Not me keeping the duplicated NAME line exactly as it is, because bestie: facts are facts and the name is the name. π
β¨ Synopsis β¨
Both of these are constexpr and noexcept, and both are since C++20. Here's the exact signature vibe:
constexpr unsigned c_encoding() const noexcept; (1) (since C++20)
constexpr unsigned iso_encoding() const noexcept; (2) (since C++20)
- Returns the weekday value stored in
*this. - Returns the weekday value stored in
*this, except that Sunday (stored as0) is interpreted as7according to ISO 8601.
So like, c_encoding() is the plain stored value, and iso_encoding() does the Sunday glow-up. Iconic. πΈ
π Return value π
- The weekday value stored in
*this. c_encoding() == 0u ? 7u : c_encoding()
That's it. That's the whole return-value section. Slay. π
π¦ Example π¦
The page literally says // Run this code, so run it, bestie:
#include <chrono>
#include <iostream>
int main()
{
std::cout << "i: C: ISO: Weekday:\n";
for (unsigned i{0}; i != 8; ++i)
{
const std::chrono::weekday w{i};
std::cout << i << " "
<< w.c_encoding() << " "
<< w.iso_encoding() << " "
<< w << '\n';
}
}
π Output π
i: C: ISO: Weekday:
0 0 7 Sun
1 1 1 Mon
2 2 2 Tue
3 3 3 Wed
4 4 4 Thu
5 5 5 Fri
6 6 6 Sat
7 0 7 Sun
The way the table goes from 7 back to Sun is highkey a vibe check. π«Ά
kisses and good vibes π β this one came from http://cppreference.com, dated 2024.06.10, and its footer title is std::chrono...iso_encoding(3). Periodt. π
π¦ 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