std::chrono...o::gps_time)(3)
β¨ 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%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 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.
π¨ Iffrom_streamfails 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 widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%NCβ parses the century as a decimal number, with widthNspecifying 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β 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 widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Nyβ parses the last two decimal digits of the year, with widthNspecifying the maximum number of characters to read. The default width is2. 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%Eyinterprets the locale's alternative representation.%Oyβ the modified command%Oyinterprets the locale's alternative representation.%Yβ 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.%NYβ parses the year as a decimal number, with widthNspecifying 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β 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 widthNspecifies the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Nmβ parses the month as a decimal number (January is 1), with widthNspecifying 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β 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.%Ndβ parses the day of month as a decimal number, with widthNspecifying the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Odβ the modified command%Odinterprets 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%Oeinterprets 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 is1. The widthNspecifies the maximum number of characters to read. The default width is1. Leading zeroes are permitted but not required.%Nuβ parses the ISO weekday as a decimal number (1-7), where Monday is1, with widthNspecifying the maximum number of characters to read. The default width is1. Leading zeroes are permitted but not required.%wβ 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.%Nwβ parses the weekday as a decimal number (0-6), where Sunday is0, with widthNspecifying 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β 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.%Ngβ parses the last two decimal digits of the ISO 8601 week-based year, with widthNspecifying the maximum number of characters to read. The default width is2. Leading zeroes are permitted but not required.%Gβ 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.%NGβ parses the ISO 8601 week-based year as a decimal number, with widthNspecifying the maximum number of characters to read. The default width is4. Leading zeroes are permitted but not required.%Vβ 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.%NVβ parses the ISO 8601 week of the year as a decimal number, with widthNspecifying the maximum number of characters to read. The default width is2. 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 widthNspecifies the maximum number of characters to read. The default width is3. Leading zeroes are permitted but not required.%Njβ parses the day of the year as a decimal number (January 1 is 1), with widthNspecifying the maximum number of characters to read. The default width is3. 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 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.%NUβ parses the week number of the year as a decimal number, with the same first-Sunday/week-01/week-00rules. 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β 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.%NWβ parses the week number of the year as a decimal number, with the same first-Monday/week-01/week-00rules. 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β 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%Exinterprets the locale's alternate date representation.
π°οΈ Time of day π°οΈ
%Hβ 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.%NHβ parses the hour (24-hour clock) as a decimal number, with widthNspecifying 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β 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.%NIβ parses the hour (12-hour clock) as a decimal number, with widthNspecifying 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β 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.%NMβ parses the minute as a decimal number, with widthNspecifying 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β 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.%NSβ parses the second as a decimal number, with widthNspecifying 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.%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. 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%Ezand%Ozparses 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%zbut 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 charactersAthroughZ,athroughz,0through9,-,+,_, 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
- 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