---
name: "std::time_get"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::time_get"
---

# std::time\_get(3)

Primary class template time\_get.

## NAME

std::time\_get\< \_CharT, \_InIter \> - Primary class template time\_get.

## 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) const\
 **iter\_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) const\
 **iter\_type** **\_M\_extract\_via\_format** (**iter\_type** \_\_beg, **iter\_type** \_\_end, **ios\_base** &\_\_io, **ios\_base::iostate** &\_\_err, tm \*\_\_tm, const \_CharT \*\_\_format) const\
 **iter\_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) const\
 **iter\_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) const\
 virtual 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.

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

References **std::locale::facet::facet()**.

### 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 **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 **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 to struct tm to 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**, **std::use\_facet()**, and **std::\_\_ctype\_abstract\_base\< \_CharT \>::widen()**.

Referenced by **get()**, and **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 to struct tm to fill in.

**Returns**

Iterator to first char beyond date string.

References **std::ios\_base::\_M\_getloc()**, **std::ios\_base::eofbit**, and **std::use\_facet()**.

Referenced by **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 to struct tm to fill in.

**Returns**

Iterator to first char beyond month name.

References **std::ios\_base::\_M\_getloc()**, **std::ios\_base::eofbit**, **std::ios\_base::failbit**, **std::ios\_base::goodbit**, and **std::use\_facet()**.

Referenced by **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 to struct tm to fill in.

**Returns**

Iterator to first char beyond time string.

References **std::ios\_base::\_M\_getloc()**, **std::ios\_base::eofbit**, and **std::use\_facet()**.

Referenced by **get\_time()**.

### 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\]

Parse input weekday string. This function parses a weekday 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\_weekday() 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 to struct tm to fill in.

**Returns**

Iterator to first char beyond weekday name.

References **std::ios\_base::\_M\_getloc()**, **std::ios\_base::eofbit**, **std::ios\_base::failbit**, **std::ios\_base::goodbit**, and **std::use\_facet()**.

Referenced by **get\_weekday()**.

### 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\]

Parse input year string. This function reads up to 4 characters to parse a year string 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\_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 to struct tm to fill in.

**Returns**

Iterator to first char beyond year.

References **std::ios\_base::\_M\_getloc()**, **std::ios\_base::eofbit**, **std::ios\_base::failbit**, **std::ios\_base::goodbit**, **std::\_\_ctype\_abstract\_base\< \_CharT \>::narrow()**, and **std::use\_facet()**.

Referenced by **get\_year()**.

### 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\]

Parse input string according to format. This function calls time\_get::do\_get with the provided parameters.

**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 to struct tm to fill in. \
 *\_\_format* Format specifier. \
 *\_\_modifier* Format modifier.

**Returns**

Iterator to first char not parsed.

References **do\_get()**.

### template\<typename \_CharT, typename \_InIter\> \_InIter 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\]

Parse input string according to format. This function parses the input string according to a provided format string. It does the inverse of time\_put::put. The format string follows the format specified for [strftime(3)](/strftime/3.md)/[strptime(3)](/strptime/3.md). 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 to struct tm to fill in. \
 *\_\_fmt* Start of the format string. \
 *\_\_fmtend* End of the format string.

**Returns**

Iterator to first char not parsed.

References **std::ios\_base::\_M\_getloc()**, **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()**, **std::\_\_ctype\_abstract\_base\< \_CharT \>::toupper()**, and **std::use\_facet()**.

### 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\]

Parse input date string. This function parses a date according to the format *x* and puts the results into a user-supplied struct tm. The result is returned by calling time\_get::do\_get\_date().

If there is a valid date string according to format *x*, *tm* will be filled in accordingly and the returned iterator will point 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 to struct tm to fill in.

**Returns**

Iterator to first char beyond date string.

References **do\_get\_date()**.

### 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\]

Parse input month string. This function parses a month name and puts the results into a user-supplied struct tm. The result is returned by calling time\_get::do\_get\_monthname().

Parsing 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 to struct tm to fill in.

**Returns**

Iterator to first char beyond month name.

References **do\_get\_monthname()**.

### 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\]

Parse input time string. This function parses a time according to the format *X* and puts the results into a user-supplied struct tm. The result is returned by calling time\_get::do\_get\_time().

If there is a valid time string according to format *X*, *tm* will be filled in accordingly and the returned iterator will point to the first character beyond the time 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 to struct tm to fill in.

**Returns**

Iterator to first char beyond time string.

References **do\_get\_time()**.

### 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\]

Parse input weekday string. This function parses a weekday name and puts the results into a user-supplied struct tm. The result is returned by calling time\_get::do\_get\_weekday().

Parsing starts by parsing 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.

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 to struct tm to fill in.

**Returns**

Iterator to first char beyond weekday name.

References **do\_get\_weekday()**.

### 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\]

Parse input year string. This function reads up to 4 characters to parse a year string and puts the results into a user-supplied struct tm. The result is returned by calling time\_get::do\_get\_year().

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 to struct tm to fill in.

**Returns**

Iterator to first char beyond year.

References **do\_get\_year()**.

## Member Data Documentation

### template\<typename \_CharT, typename \_InIter\> locale::id std::time\_get\< \_CharT, \_InIter \>::id \[static\]

Numpunct facet id.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
