std::chrono...:file_time)(3)
๐ 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
%Zis used and successfully parsed, the parsed value is assigned to*abbrevifabbrevis not null. - If the format specifier
%zor a modified variant is used and successfully parsed, the parsed value is assigned to*offsetifoffsetis not null, and the parsed offset will be subtracted from the parsed timestamp before the difference is assigned totp.
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%Zspecifier.offsetโ if not null, pointer to an object that will hold the offset from UTC corresponding to the%zspecifier.
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 widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%ECโ the modified command%ECinterprets 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 years1969to1999, and values in the range[00, 68]are presumed to refer to the years2000to2068. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Ey,%Oyโ the modified commands%Eyand%Oyinterpret the localeโs alternative representation.%Y,%NYโ parses the year as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is4. Leading zeroes are permitted but not required.%EYโ the modified command%EYinterprets 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 is1). The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Omโ the modified command%Ominterprets the localeโs alternative representation.
Day ๐ฆ
%d,%Nd,%e,%Neโ parses the day of month as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Od,%Oeโ the modified commands%Odand%Oeinterpret 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 is1. The widthNspecifies the maximum number of characters to read. The default width is1. Leading zeroes are permitted but not required.%w,%Nwโ parses the weekday as a decimal number (0-6), where Sunday is0. The widthNspecifies the maximum number of characters to read. The default width is1. Leading zeroes are permitted but not required.%Owโ the modified command%Owinterprets 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 widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%G,%NGโ parses the ISO 8601 week-based year as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is4. Leading zeroes are permitted but not required.%V,%NVโ parses the ISO 8601 week of the year as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2. 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 is1). The widthNspecifies the maximum number of characters to read. The default width is3. 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 week01. Days of the same year prior to that are in week00. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%OUโ the modified command%OUinterprets 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 week01. Days of the same year prior to that are in week00. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%OWโ the modified command%OWinterprets 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%Exinterprets the localeโs alternate date representation.
Time of day โญ
%H,%NHโ parses the hour (24-hour clock) as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%OHโ the modified command%OHinterprets the localeโs alternative representation.%I,%NIโ parses the hour (12-hour clock) as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%OIโ the modified command%OIinterprets the localeโs alternative representation.%M,%NMโ parses the minute as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%OMโ the modified command%OMinterprets the localeโs alternative representation.%S,%NSโ parses the second as a decimal number. The widthNspecifies the maximum number of characters to read. The default width is2ifDurationis convertible tostd::chrono::seconds, otherwise it is determined by the decimal precision ofDurationand the field is interpreted as along doublein 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%OSinterprets 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%EXinterprets 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%Ecinterprets the locale's alternative date and time representation. โจ%zโ parses the offset from UTC in the format[+|-]hh[mm]. For example,-0430refers to 4 hours 30 minutes behind UTC and04refers to 4 hours ahead of UTC. โฐ%Ez,%Ozโ the modified commands%Ezand%Ozparses 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 charactersAthroughZ,athroughz,0through9,-,+,_, 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
- 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