std::chrono...o::gps_time)(3)

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

✨ NAME ✨

okay so this is the manual page for std::chrono::from_stream(std::chrono::gps_time) β€” yes, the whole std::chrono::from_stream(std::chrono::gps_time) situation β€” from the C++ Standard Libary, section 3. This is part 1 of 3, bestie, so hydrate and stay with me πŸ’–.

πŸ’… Synopsis πŸ’…

Here's the signature, exactly as it appears, no editing, no cap:

          template< class CharT, class Traits, class Duration, 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::gps_time<Duration>& tp,
                           std::basic_string<CharT, Traits, Alloc>* abbrev =
          nullptr,

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

So what does it do? It attempts to parse the input stream is into the time point tp according to the format string fmt. That's the whole assignment, lowkey.

It behaves as an UnformattedInputFunction, with one spicy exception: it has an unspecified effect on is.gcount(). After constructing and checking the sentry object, it attempts to parse the input stream is into tp according to the format string fmt. If the parse fails to decode a valid time point, is.setstate(std::ios_base::failbit) is called and tp is not modified. So if it flops, your tp stays untouched β€” iconic failbit behavior, not a silent corruption moment 😭.

⚠️ caveat, bestie: that unspecified effect on is.gcount() is literally in the spec, so don't go assuming anything cute about it πŸ’€.

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, and the parsed offset will be subtracted from the parsed timestamp before the difference is assigned to tp. That subtraction detail is important β€” don't skip it πŸ’….

πŸ’– Parameters πŸ’–

These are the inputs doing the work, bestie:

  • is β€” an input stream.
  • fmt β€” a format string (see below).
  • tp β€” time point 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.

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 breakdown 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.

🚨 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.

The following conversion specifiers are available:

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

🌸 Year 🌸

  • %C β€” 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.
  • %NC β€” parses the century as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %EC β€” the modified command %EC interprets the locale's alternative representation of the century.
  • %y β€” 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.
  • %Ny β€” parses the last two decimal digits of the year, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required. If the century is not otherwise specified, the same [69, 99] and [00, 68] year rules above apply.
  • %Ey β€” the modified command %Ey interprets the locale's alternative representation.
  • %Oy β€” the modified command %Oy interprets the locale's alternative representation.
  • %Y β€” 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.
  • %NY β€” parses the year as a decimal number, with width N specifying the maximum number of characters to read. The default width is 4. Leading zeroes are permitted but not required.
  • %EY β€” the modified command %EY interprets the locale's alternative representation.

🌷 Month 🌷

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

πŸ¦‹ Day πŸ¦‹

  • %d β€” 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.
  • %Nd β€” parses the day of month as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %Od β€” the modified command %Od interprets the locale's alternative representation.
  • %e β€” this specifier sits in the day-of-month cluster on the page, but no separate description is attached to it.
  • %Ne β€” this specifier also sits in the day-of-month cluster on the page, but no separate description is attached to it.
  • %Oe β€” the modified command %Oe interprets the locale's alternative representation.

🌼 Day of the week 🌼

  • %a β€” parses the locale's full or abbreviated case-insensitive weekday name.
  • %A β€” parses the locale's full or abbreviated case-insensitive weekday name.
  • %u β€” 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.
  • %Nu β€” parses the ISO weekday as a decimal number (1-7), where Monday is 1, with width N specifying the maximum number of characters to read. The default width is 1. Leading zeroes are permitted but not required.
  • %w β€” 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.
  • %Nw β€” parses the weekday as a decimal number (0-6), where Sunday is 0, with width N specifying the maximum number of characters to read. The default width is 1. Leading zeroes are permitted but not required.
  • %Ow β€” 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 β€” 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.
  • %Ng β€” parses the last two decimal digits of the ISO 8601 week-based year, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %G β€” 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.
  • %NG β€” parses the ISO 8601 week-based year as a decimal number, with width N specifying the maximum number of characters to read. The default width is 4. Leading zeroes are permitted but not required.
  • %V β€” 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.
  • %NV β€” parses the ISO 8601 week of the year as a decimal number, with width N specifying 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 β€” 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.
  • %Nj β€” parses the day of the year as a decimal number (January 1 is 1), with width N specifying the maximum number of characters to read. The default width is 3. Leading zeroes are permitted but not required.
  • %U β€” 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.
  • %NU β€” parses the week number of the year as a decimal number, with the same first-Sunday/week-01/week-00 rules. Width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %OU β€” the modified command %OU interprets the locale's alternative representation.
  • %W β€” 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.
  • %NW β€” parses the week number of the year as a decimal number, with the same first-Monday/week-01/week-00 rules. Width N specifies the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %OW β€” the modified command %OW interprets the locale's alternative representation.

πŸŽ€ Date πŸŽ€

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

πŸ•°οΈ Time of day πŸ•°οΈ

  • %H β€” 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.
  • %NH β€” parses the hour (24-hour clock) as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %OH β€” the modified command %OH interprets the locale's alternative representation.
  • %I β€” 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.
  • %NI β€” parses the hour (12-hour clock) as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %OI β€” the modified command %OI interprets the locale's alternative representation.
  • %M β€” 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.
  • %NM β€” parses the minute as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2. Leading zeroes are permitted but not required.
  • %OM β€” the modified command %OM interprets the locale's alternative representation.
  • %S β€” parses the second as a decimal number. The width N specifies the maximum number of characters to read. The default width is 2 if Duration is convertible to std::chrono::seconds; otherwise it is determined by the decimal precision of Duration and the field is interpreted as a long double in a fixed format, with the decimal point character determined by the locale (if encountered). Leading zeroes are permitted but not required.
  • %NS β€” parses the second as a decimal number, with width N specifying the maximum number of characters to read. The default width is 2 if Duration is convertible to std::chrono::seconds; otherwise it is determined by the decimal precision of Duration and the field is interpreted as a long double in a fixed format, with the decimal point character determined by the locale (if encountered). Leading zeroes are permitted but not required.
  • %OS β€” 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 β€” parses the locale's time representation.
  • %EX β€” the modified command %EX interprets the locale's alternate time representation.
  • %c β€” parses the locale's date and time representation.
  • %Ec β€” the modified command %Ec interprets the locale's alternative date and time representation.
  • %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. bestie this one is so useful, it's literally how you find out where in the world a timestamp is at 🌍
  • %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). so it's the same vibe as %z but lowkey stricter about your colon and more chill about your leading zero πŸ’…
  • %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 /. no cap, that's the whole allowed alphabet β€” anything else and the run just stops there πŸ›‘

✨ Return value ✨

okay so the page says the return value is

is

and then it just... ends 😭 that's the whole thing. it's giving cut-off-at-the-drive-thru. not me reading that three times hoping more words would load πŸ™ˆ


✨ Example ✨

This section is incomplete Reason: no example

the page is literally telling on itself 🫠 no example bestie, we're on our own. iconic of it to admit it tho.


🌈 See also 🌈

  • parse β€” parses a chrono object from a stream β€” (C++20) (function template). this is the one, she's the main character of the neighbor list πŸ‘‘

πŸŽ€ Category πŸŽ€

  • * Todo no example

and that's a wrap on the whole page, bestie!! πŸ¦‹ source is cppreference.com, dated 2024.06.10, and the page is std::chrono...o::gps_time)(3) β€” go forth and parse those timestamps, you absolute legend πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from