STD::TIME_GET(3cxx)
π°οΈ std::time_get< _CharT, _InIter >(3cxx) β manual page, bestie π
β¨ NAME β¨
std::time_get< _CharT, _InIter > β Primary class template time_get. Thatβs the whole vibe: itβs the locale facet that parses dates and times out of strings, and itβs lowkey iconic. π
π¦ SYNOPSIS π¦
#include <locale>
Inherits std::locale::facet, and std::time_base.
Inherited by std::time_get_byname< _CharT, _InIter >.
π Public Types π
enum dateorder { no_order, dmy, mdy, ymd, ydm }typedef _CharT char_typeβ Public typedefs.typedef _InIter iter_typeβ Public typedefs.
πΈ Public Member Functions πΈ
time_get (size_t __refs=0)β Constructor performs initialization.dateorder date_order () constβ Return preferred order of month, day, and year.iter_type get (iter_type __s, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm, char __format, char __modifier=0) constβ Parse input string according to format.iter_type get (iter_type __s, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm, const char_type *__fmt, const char_type *__fmtend) constβ Parse input string according to format.iter_type get_date (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input date string.iter_type get_monthname (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input month string.iter_type get_time (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input time string.iter_type get_weekday (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input weekday string.iter_type get_year (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input year string.
π Static Public Attributes π
static locale::id idβ Numpunct facet id.
π§ Protected Member Functions π§
virtual ~time_get ()β Destructor.iter_type _M_extract_name (iter_type __beg, iter_type __end, int &__member, const _CharT **__names, size_t __indexlen, ios_base &__io, ios_base::iostate &__err) constiter_type _M_extract_num (iter_type __beg, iter_type __end, int &__member, int __min, int __max, size_t __len, ios_base &__io, ios_base::iostate &__err) constiter_type _M_extract_via_format (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm, const _CharT *__format) constiter_type _M_extract_via_format (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm, const _CharT *__format, __time_get_state &__state) constiter_type _M_extract_wday_or_month (iter_type __beg, iter_type __end, int &__member, const _CharT **__names, size_t __indexlen, ios_base &__io, ios_base::iostate &__err) constvirtual dateorder do_date_order () constβ Return preferred order of month, day, and year.iter_type do_get (iter_type __s, iter_type __end, ios_base &__f, ios_base::iostate &__err, tm *__tm, char __format, char __modifier) constβ Parse input string according to format.virtual iter_type do_get_date (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input date string.virtual iter_type do_get_monthname (iter_type __beg, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__tm) constβ Parse input month string.virtual iter_type do_get_time (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input time string.virtual iter_type do_get_weekday (iter_type __beg, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__tm) constβ Parse input weekday string.virtual iter_type do_get_year (iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) constβ Parse input year string.
π Static Protected Member Functions π
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)static void _S_destroy_c_locale (__c_locale &__cloc)static __c_locale _S_get_c_locale ()static const char * _S_get_c_name () throw ()static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)
π Detailed Description π
template<typename _CharT, typename _InIter>
class std::time_get< _CharT, _InIter >
Primary class template time_get.
This facet encapsulates the code to parse and return a date or time from a string. It is used by the istream numeric extraction operators.
The time_get template uses protected virtual functions to provide the actual results. The public accessors forward the call to the virtual functions. These virtual functions are hooks for developers to implement the behavior they require from the time_get facet. No cap. π«Ά
π Member Typedef Documentation π
template<typename _CharT , typename _InIter > typedef _CharT std::time_get< _CharT, _InIter >::char_typeβ Public typedefs.template<typename _CharT , typename _InIter > typedef _InIter std::time_get< _CharT, _InIter >::iter_typeβ Public typedefs.
π Constructor & Destructor Documentation π
template<typename _CharT , typename _InIter > std::time_get< _CharT, _InIter >::time_get (size_t __refs = 0) [inline], [explicit]
Constructor performs initialization. This is the constructor provided by the standard.
Parameters
__refsβ Passed to the base facet class.
template<typename _CharT , typename _InIter > virtual std::time_get< _CharT, _InIter >::~time_get () [inline], [protected], [virtual]
Destructor.
π Member Function Documentation π
template<typename _CharT , typename _InIter > dateorder std::time_get< _CharT, _InIter >::date_order () const [inline]
Return preferred order of month, day, and year. This function returns an enum from time_base::dateorder giving the preferred ordering if the format x given to time_put::put() only uses month, day, and year. If the format x for the associated locale uses other fields, this function returns time_base::dateorder::noorder.
NOTE: The library always returns noorder at the moment. π
Returns
- A member of
time_base::dateorder.
References
std::time_get< _CharT, _InIter >::do_date_order().
template<typename _CharT , typename _InIter > _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 time_base::dateorder std::time_get< _CharT, _InIter >::do_date_order () const [protected], [virtual]
Return preferred order of month, day, and year. This function returns an enum from time_base::dateorder giving the preferred ordering if the format x given to time_put::put() only uses month, day, and year. This function is a hook for derived classes to change the value returned.
Returns
- A member of
time_base::dateorder.
Referenced by
std::time_get< _CharT, _InIter >::date_order().
template<typename _CharT , typename _InIter > _InIter std::time_get< _CharT, _InIter >::do_get (iter_type __s, iter_type __end, ios_base & __f, ios_base::iostate & __err, tm * __tm, char __format, char __modifier) const [inline], [protected]
Parse input string according to format. This function parses the string according to the provided format and optional modifier. This function is a hook for derived classes to change the value returned.
See also
get()for more details.
Parameters
__sβ Start of string to parse.__endβ End of string to parse.__fβ Source of the locale.__errβ Error flags to set.__tmβ Pointer tostruct tmto fill in.__formatβ Format specifier.__modifierβ Format modifier.
Returns
- Iterator to first char not parsed.
References
std::ios_base::_M_getloc(),std::ios_base::eofbit,std::ios_base::goodbit, andstd::__ctype_abstract_base< _CharT >::widen().
Referenced by
std::time_get< _CharT, _InIter >::get(), andstd::time_get< _CharT, _InIter >::get().
template<typename _CharT , typename _InIter > _InIter std::time_get< _CharT, _InIter >::do_get_date (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, tm * __tm) const [protected], [virtual]
Parse input date string. This function parses a date according to the format X and puts the results into a user-supplied struct tm. This function is a hook for derived classes to change the value returned.
See also
get_date()for details.
Parameters
__begβ Start of string to parse.__endβ End of string to parse.__ioβ Source of the locale.__errβ Error flags to set.__tmβ Pointer tostruct tmto fill in.
Returns
- Iterator to first char beyond date string.
References
std::ios_base::_M_getloc(), andstd::ios_base::eofbit.
Referenced by
std::time_get< _CharT, _InIter >::get_date().
template<typename _CharT , typename _InIter > _InIter std::time_get< _CharT, _InIter >::do_get_monthname (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, tm * __tm) const [protected], [virtual]
Parse input month string. This function parses a month name and puts the results into a user-supplied struct tm. This function is a hook for derived classes to change the value returned.
See also
get_monthname()for details.
Parameters
__begβ Start of string to parse.__endβ End of string to parse.__ioβ Source of the locale.__errβ Error flags to set.__tmβ Pointer tostruct tmto fill in.
Returns
- Iterator to first char beyond month name.
References
std::ios_base::_M_getloc(),std::ios_base::eofbit,std::ios_base::failbit, andstd::ios_base::goodbit.
Referenced by
std::time_get< _CharT, _InIter >::get_monthname().
template<typename _CharT , typename _InIter > _InIter std::time_get< _CharT, _InIter >::do_get_time (iter_type __beg, iter_type __end, ios_base & __io, ios_base::iostate & __err, tm * __tm) const [protected], [virtual]
Parse input time string. This function parses a time according to the format x and puts the results into a user-supplied struct tm. This function is a hook for derived classes to change the value returned.
See also
get_time()for details.
Parameters
__begβ Start of string to parse.__endβ End of string to parse.__ioβ Source of the locale.__errβ Error flags to set.__tmβ Pointer tostruct tmto fill in.
Returns
- Iterator to first char beyond time string.
References
std::ios_base::_M_getloc(), andstd::ios_base::eofbit.
Referenced by
std::time_get< _CharT, _InIter >::get_time().
π¦ do_get_weekday β the protected hook
template<typename _CharT , typename _InIter >
_InIter std::time_get< _CharT, _InIter >::do_get_weekday(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[protected], [virtual]
Okay so this is the one that parses a weekday name out of your input string and drops the results into a user-supplied struct tm β¨. It's a hook for derived classes to change the value returned β so if you're subclassing, this is your moment, bestie, main character energy fr fr.
See also: get_weekday() for the full deets π
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the weekday name π―
References: std::ios_base::_M_getloc(), std::ios_base::eofbit, std::ios_base::failbit, and std::ios_base::goodbit.
Referenced by: std::time_get< _CharT, _InIter >::get_weekday().
πΈ do_get_year β the other protected hook
template<typename _CharT , typename _InIter >
_InIter std::time_get< _CharT, _InIter >::do_get_year(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[protected], [virtual]
This one reads up to 4 characters to parse a year string and pops the results into a user-supplied struct tm π. Same deal as before: it's a hook for derived classes to change the value returned.
See also: get_year() for details π«Ά
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the year β
References: std::ios_base::_M_getloc(), std::ios_base::eofbit, std::ios_base::failbit, std::ios_base::goodbit, and std::__ctype_abstract_base< _CharT >::narrow().
Referenced by: std::time_get< _CharT, _InIter >::get_year().
π get β the char __format version
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get(iter_type __s, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm,
char __format, char __modifier = 0) const
[inline]
Parses your input string according to a format, and it literally just calls time_get::do_get with the provided parameters. Short king behavior, no notes π
See also: do_get() and get() π
Parameters:
__sβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.__formatβ format specifier.__modifierβ format modifier (defaults to0).
Returns: iterator to the first char not parsed.
References: std::time_get< _CharT, _InIter >::do_get().
π get β the format-string version
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get(iter_type __s, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm,
const char_type* __fmt, const char_type* __fmtend) const
[inline]
This is the big one, and it's giving reverse-engineering icon: it parses the input string according to a provided format string, which means it does the inverse of time_put::put π₯. Your format string follows the format specified for strftime(3) / strptime(3), and the actual parsing is done by time_get::do_get.
Parameters:
__sβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.__fmtβ start of the format string.__fmtendβ end of the format string.
Returns: iterator to the first char not parsed.
References: std::ios_base::_M_getloc(), std::time_get< _CharT, _InIter >::do_get(), std::ios_base::eofbit, std::ios_base::failbit, std::ios_base::goodbit, std::__ctype_abstract_base< _CharT >::is(), std::__ctype_abstract_base< _CharT >::narrow(), std::__ctype_abstract_base< _CharT >::tolower(), and std::__ctype_abstract_base< _CharT >::toupper().
π§ get_date β format x supremacy
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get_date(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[inline]
Parses a date according to the format x and puts the results into your user-supplied struct tm. The result comes back via time_get::do_get_date() π―
Okay so here's the vibe check on what happens π β if there's a valid date string according to formatx,tmgets filled in accordingly and the returned iterator points to the first character beyond the date string. If an error occurs before the end,err |= ios_base::failbit. If parsing reads all the characters,err |= ios_base::eofbit.
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the date string.
References: std::time_get< _CharT, _InIter >::do_get_date().
π get_monthname β abbreviations first, obvs
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get_monthname(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[inline]
Parses a month name into your user-supplied struct tm, result returned by calling time_get::do_get_monthname() πΈ
The way parsing works: it starts by parsing an abbreviated month name. If a valid abbreviation is followed by a character that would lead to the full month name, parsing continues until the full name is found or an error occurs. Otherwise parsing finishes at the end of the abbreviated name β¨
If an error occurs before the end,err |= ios_base::failbit. If parsing reads all the characters,err |= ios_base::eofbit.
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the month name.
References: std::time_get< _CharT, _InIter >::do_get_monthname().
π¦ get_time β format X, not the other X
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get_time(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[inline]
Parses a time according to the format X into your user-supplied struct tm. Result is returned by calling time_get::do_get_time() π
Valid time string according to formatX? Thentmgets filled in accordingly and the returned iterator points to the first character beyond the time string. Error before the end?err |= ios_base::failbit. Parsing reads all the characters?err |= ios_base::eofbit.
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the time string.
References: std::time_get< _CharT, _InIter >::do_get_time().
β get_weekday β the public-facing one
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get_weekday(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[inline]
Parses a weekday name into your user-supplied struct tm, with the result returned by calling time_get::do_get_weekday() π«Ά
Same abbreviation dance as month names, ngl: parsing starts with an abbreviated weekday name. If a valid abbreviation is followed by a character that would lead to the full weekday name, parsing continues until the full name is found or an error occurs. Otherwise parsing finishes at the end of the abbreviated name π
Error before the end βerr |= ios_base::failbit. Parsing reads all the characters βerr |= ios_base::eofbit.
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the weekday name.
References: std::time_get< _CharT, _InIter >::do_get_weekday().
π get_year β the 2-digit vs 4-digit lore
template<typename _CharT , typename _InIter >
iter_type std::time_get< _CharT, _InIter >::get_year(iter_type __beg, iter_type __end,
ios_base& __io, ios_base::iostate& __err, tm* __tm) const
[inline]
Reads up to 4 characters to parse a year string into your user-supplied struct tm, and the result is returned by calling time_get::do_get_year() π₯
The rules, bestie, listen up:
- 4 consecutive digits are interpreted as a full year β¨
- If there are exactly 2 consecutive digits, the library interprets this as the number of years since 1900 π
If an error occurs before the end,err |= ios_base::failbit. If parsing reads all the characters,err |= ios_base::eofbit.
Parameters:
__begβ start of string to parse.__endβ end of string to parse.__ioβ source of the locale.__errβ error flags to set.__tmβ pointer tostruct tmto fill in.
Returns: iterator to the first char beyond the year.
References: std::time_get< _CharT, _InIter >::do_get_year().
ποΈ MEMBER DATA DOCUMENTATION
π§ id
template<typename _CharT , typename _InIter >
locale::id std::time_get< _CharT, _InIter >::id
[static]
Numpunct facet id. That's it, that's the whole description, she's concise π
π AUTHOR
Generated automatically by Doxygen for libstdc++ from the source code. Iconic. No human hands typed this, it just manifested π§
and that's the whole page, bestie!! ππβ¨
This little beauty lives at libstdstd::time_get< _CharT, _InIter >(3cxx) β that's the source/version tag chilling in the footer β and it's stamped with its date right down there at the bottom of the page, auto-generated for libstdc++ from the source code. Go forth and parse those dates, you absolute icon π«Άπ
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms