std::chrono...:file_time)(3)

๐Ÿ“ฆ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’… NAME ๐Ÿ’…

std::chrono::from_stream(std::chrono::file_time) โ€” std::chrono::from_stream(std::chrono::file_time)

Okay bestie, welcome to std::chrono...:file_time)(3) from the C++ Standard Libary manual ๐Ÿ’– This one is literally all about the std::chrono::file_time overload of std::chrono::from_stream, and it is giving chrono-parsing main character energy, no cap.


โœจ Synopsis โœจ

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

                 std::chrono::minutes* offset = nullptr );
(since C++20) โ€” yes bestie, this overload is since C++20, periodt ๐Ÿ’…

So what does it actually do? It attempts to parse the input stream is into the time point tp according to the format string fmt ๐Ÿซถ

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 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 ๐Ÿ˜ญ

And here's the format-specifier tea โ˜•:

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

part 1 of 3 โ€” more of the page is literally coming, bestie ๐Ÿ’œ

Parameters ๐Ÿ’–

Okay bestie, hereโ€™s the cast of characters for this overload:

  • is โ€” an input stream. This is the stream weโ€™re reading from.
  • fmt โ€” a format string (see below). This is the instruction manual for the parse.
  • tp โ€” time point object to hold the parse result. Itโ€™s where the parsed time lands.
  • 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 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.

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, %NC โ€” 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.
  • %EC โ€” the modified command %EC interprets the localeโ€™s alternative representation of the century.
  • %y, %Ny โ€” 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.
  • %Ey, %Oy โ€” the modified commands %Ey and %Oy interpret the localeโ€™s alternative representation.
  • %Y, %NY โ€” 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.
  • %EY โ€” 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 โ€” 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.
  • %Om โ€” the modified command %Om interprets the localeโ€™s alternative representation.

Day ๐Ÿฆ‹

  • %d, %Nd, %e, %Ne โ€” 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.
  • %Od, %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 โ€” 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.
  • %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, %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 โ€” 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.
  • %OU โ€” the modified command %OU interprets the localeโ€™s alternative representation.
  • %W, %NW โ€” 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.
  • %OW โ€” 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 โ€” parses the localeโ€™s date representation.
  • %Ex โ€” the modified command %Ex interprets the localeโ€™s alternate date representation.

Time of day โญ

  • %H, %NH โ€” 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.
  • %OH โ€” the modified command %OH interprets the localeโ€™s alternative representation.
  • %I, %NI โ€” 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.
  • %OI โ€” the modified command %OI interprets the localeโ€™s alternative representation.
  • %M, %NM โ€” 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.
  • %OM โ€” the modified command %OM interprets the localeโ€™s alternative representation.
  • %S, %NS โ€” 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.
  • %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.

Miscellaneous ๐ŸŒธ

okay so these are the last format-specifier vibes, and they are lowkey iconic:

  • %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. โฐ
  • %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). ๐Ÿ’…
  • %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 /. ๐ŸŒˆ

Return value ๐Ÿ’€

bestie, the page literally just says: is. That's the whole return-value moment. no cap. ๐Ÿ˜ญ

Example ๐Ÿ“

This section is incomplete. Reason: no example.

See also ๐Ÿ‘€

  • parse โ€” parses a chrono object from a stream (C++20) (function template). ๐Ÿซถ

Category: ๐Ÿ—‚๏ธ

  • Todo no example

and that's the page, bestie ๐Ÿ’– source: http://cppreference.com ยท version/date: 2024.06.10 โœจ

๐Ÿ“ฆ where this page comes from