std::chrono...r_month_day)(3)

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

🌸 NAME 🌸

okay bestie, welcome to the std::chrono...r_month_day)(3) page from the C++ Standard Libary β€” part 1 of 3, and it’s literally all about std::chrono::from_stream(std::chrono::year_month_day). no cap πŸ’…


✨ Synopsis ✨

Defined in header <chrono>
template< class CharT, class Traits, class Alloc =
std::allocator<CharT> >

std::basic_istream<CharT, Traits>&
    from_stream( std::basic_istream<CharT, Traits>& is, const CharT*
fmt,
(since C++20)
                 std::chrono::year_month_day& ymd,
                 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,

                 std::chrono::minutes* offset = nullptr );

okay so the whole vibe is this: it attempts to parse the input stream is into the std::chrono::year_month_day ymd according to the format string fmt. it’s giving parser main character energy πŸ”₯

it behaves as an UnformattedInputFunction, except that it has an unspecified effect on is.gcount(). after constructing and checking the sentry object, it attempts to parse the input stream is into ymd according to the format string fmt. if the parse fails to decode a valid year_month_day, is.setstate(std::ios_base::failbit) is called and ymd is not modified. periodt πŸ’€

if the format specifier %Z is used and successfully parsed, the parsed value is assigned to *abbrev if abbrev is not null. if the format specifier %z or a modified variant is used and successfully parsed, the parsed value is assigned to *offset if offset is not null. iykyk 🌟

part 1 is served, bestie β€” part 2 is loading… πŸ¦‹

πŸ’– PARAMETERS πŸ’–

  • is β€” an input stream. That's literally where the bytes come from.
  • fmt β€” a format string (see below). The blueprint, bestie.
  • ymd β€” object to hold the parse result.
  • abbrev β€” if not null, pointer to an object that will hold the time zone abbreviation or name corresponding to the %Z specifier.
  • offset β€” if not null, pointer to an object that will hold the offset from UTC corresponding to the %z specifier.

🌸 Format string 🌸

The format string consists of zero or more conversion specifiers and ordinary characters. Each ordinary character, excluding whitespace characters and the terminating null character, matches one identical character from the input stream, or causes the function to fail if the next character on the stream does not compare equal.

Each whitespace character matches zero or more whitespace characters in the input stream. Zero. It's giving flexible.

Each unmodified conversion specifier begins with a % character followed by a character that determines the behavior of the specifier. Some conversion specifiers have a modified form in which an E or O modifier character is inserted after the % character. Some conversion specifiers have a modified form in which a width parameter given as a positive decimal integer (shown as N below) is inserted after the % character. Each conversion specifier causes the matched characters to be interpreted as parts of date and time types according to the table below.

A character sequence in the format string that begins with a % but does not match one of the conversion specifiers below is interpreted as ordinary characters. Sneaky, but that's the rule.

🚨 If from_stream fails to parse everything specified by the format string, or if insufficient information is parsed to specify a complete result, or if parsing discloses contradictory information, is.setstate(std::ios_base::failbit) is called. That's a failbit moment, no cap.

The following conversion specifiers are available:

  • %% β€” Matches a literal % character.
  • %n β€” Matches one whitespace character.
  • %t β€” Matches zero or one whitespace character.

🌟 Year 🌟

  • %C, %NC, %EC β€” Parses the century as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %EC interprets the locale's alternative representation of the century.
  • %y, %Ny, %Ey, %Oy β€” Parses the last two decimal digits of the year. If the century is not otherwise specified (e.g. with %C), values in the range [69, 99] are presumed to refer to the years 1969 to 1999, and values in the range [00, 68] are presumed to refer to the years 2000 to 2068. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified commands %Ey and %Oy interpret the locale's alternative representation.
  • %Y, %NY, %EY β€” Parses the year as a decimal number. The width N specifies the maximum number of characters to read. The default width is 4. Leading zeroes are permitted but not required. The modified command %EY interprets the locale's alternative representation.

πŸŽ€ Month πŸŽ€

  • %b, %B, %h β€” Parses the locale's full or abbreviated case-insensitive month name.
  • %m, %Nm, %Om β€” Parses the month as a decimal number (January is 1). The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %Om interprets the locale's alternative representation.

πŸ¦‹ Day πŸ¦‹

  • %d, %Nd, %Od β€” Parses the day of month as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %e, %Ne, %Oe β€” The modified commands %Od and %Oe interpret the locale's alternative representation.

πŸ’… Day of the week πŸ’…

  • %a, %A β€” Parses the locale's full or abbreviated case-insensitive weekday name.
  • %u, %Nu β€” Parses the ISO weekday as a decimal number (1-7), where Monday is 1. The width N specifies the maximum number of characters to read. The default width is 1. Leading zeroes are permitted but not required.
  • %w, %Nw, %Ow β€” Parses the weekday as a decimal number (0-6), where Sunday is 0. The width N specifies the maximum number of characters to read. The default width is 1. Leading zeroes are permitted but not required. The modified command %Ow interprets the locale's alternative representation.

🌈 ISO 8601 week-based year 🌈

In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:

  • Includes January 4
  • Includes first Thursday of the year
  • %g, %Ng β€” Parses the last two decimal digits of the ISO 8601 week-based year. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %G, %NG β€” Parses the ISO 8601 week-based year as a decimal number. The width N specifies the maximum number of characters to read. The default width is 4. Leading zeroes are permitted but not required.
  • %V, %NV β€” Parses the ISO 8601 week of the year as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.

🌸 Week/day of the year 🌸

  • %j, %Nj β€” Parses the day of the year as a decimal number (January 1 is 1). The width N specifies the maximum number of characters to read. The default width is 3. Leading zeroes are permitted but not required.
  • %U, %NU, %OU β€” Parses the week number of the year as a decimal number. The first Sunday of the year is the first day of week 01. Days of the same year prior to that are in week 00. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OU interprets the locale's alternative representation.
  • %W, %NW, %OW β€” Parses the week number of the year as a decimal number. The first Monday of the year is the first day of week 01. Days of the same year prior to that are in week 00. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OW interprets the locale's alternative representation.

πŸŽ€ Date πŸŽ€

  • %D β€” Equivalent to "%m/%d/%y".
  • %F, %NF β€” Equivalent to "%Y-%m-%d". If the width is specified, it is only applied to the %Y.
  • %x, %Ex β€” Parses the locale's date representation. The modified command %Ex interprets the locale's alternate date representation.

πŸ’œ Time of day πŸ’œ

  • %H, %NH, %OH β€” Parses the hour (24-hour clock) as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OH interprets the locale's alternative representation.
  • %I, %NI, %OI β€” Parses the hour (12-hour clock) as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OI interprets the locale's alternative representation.
  • %M, %NM, %OM β€” Parses the minute as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OM interprets the locale's alternative representation.
  • %S, %NS, %OS β€” Parses the second as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. The modified command %OS interprets the locale's alternative representation.
  • %p β€” Parses the locale's equivalent of the AM/PM designations associated with a 12-hour clock.
  • %R β€” Equivalent to "%H:%M".
  • %T β€” Equivalent to "%H:%M:%S".
  • %r β€” Parses the locale's 12-hour clock time.
  • %X, %EX β€” Parses the locale's time representation. The modified command %EX interprets the locale's alternate time representation.

Miscellaneous πŸ’«

  • %c β€” parses the locale's date and time representation. the whole shebang, together, slay.
  • %Ec β€” the modified command %Ec interprets the locale's alternative date and time representation. it's giving "same energy, different outfit" ✨
  • %z β€” parses the offset from UTC in the format [+|-]hh[mm]. for example, -0430 refers to 4 hours 30 minutes behind UTC, and 04 refers to 4 hours ahead of UTC. lowkey so clean.
  • %Ez, %Oz β€” the modified commands %Ez and %Oz parses the format [+|-]h[h][:mm] (i.e., requiring a : between the hours and minutes and making the leading zero for hour optional). note that it says parses, that's how the page words it, bestie, we don't fix it πŸ’…
  • %Z β€” parses the time zone abbreviation or name, taken as the longest sequence of characters that only contains the characters A through Z, a through z, 0 through 9, -, +, _, and /. that's the whole guest list, no plus-ones πŸŽ€

Return value 🌸

is

okay so real talk β€” the page literally just says is here and then nothing 😭 like the sentence walked off mid-sentence. that's not me being mysterious, that's genuinely all the text we got. no cap.

See also πŸ¦‹

  • parse (C++20) β€” parses a chrono object from a stream (function template). the actual star of the show, fr fr πŸ‘‘

that's the whole page, bestie β€” sourced from http://cppreference.com, dated 2024.06.10, and it's a std::chrono...r_month_day)(3) moment. go forth and parse responsibly πŸ’œβœ¨

πŸ“¦ where this page comes from