---
name: "std::time_put"
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_put"
---

# std::time\_put(3)

Primary class template time\_put.

## NAME

std::time\_put\< \_CharT, \_OutIter \> - Primary class template time\_put.

## SYNOPSIS

\#include \<locale\>

Inherits **std::locale::facet**.

Inherited by **std::time\_put\_byname\< \_CharT, \_OutIter \>**.

### Public Types

typedef \_CharT **char\_type**\
 Public typedefs.  typedef \_OutIter **iter\_type**\
 Public typedefs.

### Public Member Functions

**time\_put** (size\_t \_\_refs=0)\
 Constructor performs initialization.  **iter\_type** **put** (**iter\_type** \_\_s, **ios\_base** &\_\_io, **char\_type** \_\_fill, const tm \*\_\_tm, char \_\_format, char \_\_mod=0) const\
 Format and output a time or date.  **iter\_type** **put** (**iter\_type** \_\_s, **ios\_base** &\_\_io, **char\_type** \_\_fill, const tm \*\_\_tm, const \_CharT \*\_\_beg, const \_CharT \*\_\_end) const\
 Format and output a time or date.

### Static Public Attributes

static **locale::id** **id**\
 Numpunct facet id.

### Protected Member Functions

virtual **~time\_put** ()\
 Destructor.  virtual **iter\_type** **do\_put** (**iter\_type** \_\_s, **ios\_base** &\_\_io, **char\_type** \_\_fill, const tm \*\_\_tm, char \_\_format, char \_\_mod) const\
 Format and output a time or date.

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

class std::time\_put\< \_CharT, \_OutIter \>"Primary class template time\_put.

This facet encapsulates the code to format and output dates and times according to formats used by strftime().

The time\_put 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\_put facet.

## Member Typedef Documentation

### template\<typename \_CharT, typename \_OutIter\> typedef \_CharT std::time\_put\< \_CharT, \_OutIter \>::char\_type

Public typedefs.

### template\<typename \_CharT, typename \_OutIter\> typedef \_OutIter std::time\_put\< \_CharT, \_OutIter \>::iter\_type

Public typedefs.

## Constructor & Destructor Documentation

### template\<typename \_CharT, typename \_OutIter\> std::time\_put\< \_CharT, \_OutIter \>::time\_put (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 \_OutIter\> virtual std::time\_put\< \_CharT, \_OutIter \>::~time\_put () \[inline\], \[protected\], \[virtual\]

Destructor.

## Member Function Documentation

### template\<typename \_CharT, typename \_OutIter\> \_OutIter std::time\_put\< \_CharT, \_OutIter \>::do\_put (iter\_type \_\_s, ios\_base & \_\_io, char\_type \_\_fill, const tm \* \_\_tm, char \_\_format, char \_\_mod) const \[protected\], \[virtual\]

Format and output a time or date. This function formats the data in struct tm according to the provided format char and optional modifier. This function is a hook for derived classes to change the value returned.

**See also**

put() for more details.

**Parameters**

*\_\_s* The stream to write to. \
 *\_\_io* Source of locale. \
 *\_\_fill* char\_type to use for padding. \
 *\_\_tm* Struct tm with date and time info to format. \
 *\_\_format* Format char. \
 *\_\_mod* Optional modifier char.

**Returns**

Iterator after writing.

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

Referenced by **put()**, and **put()**.

### template\<typename \_CharT, typename \_OutIter\> iter\_type std::time\_put\< \_CharT, \_OutIter \>::put (iter\_type \_\_s, ios\_base & \_\_io, char\_type \_\_fill, const tm \* \_\_tm, char \_\_format, char \_\_mod = 0) const \[inline\]

Format and output a time or date. This function formats the data in struct tm according to the provided format char and optional modifier. The format and modifier are interpreted as by strftime(). It does so by returning time\_put::do\_put().

**Parameters**

*\_\_s* The stream to write to. \
 *\_\_io* Source of locale. \
 *\_\_fill* char\_type to use for padding. \
 *\_\_tm* Struct tm with date and time info to format. \
 *\_\_format* Format char. \
 *\_\_mod* Optional modifier char.

**Returns**

Iterator after writing.

References **do\_put()**.

### template\<typename \_CharT, typename \_OutIter\> \_OutIter std::time\_put\< \_CharT, \_OutIter \>::put (iter\_type \_\_s, ios\_base & \_\_io, char\_type \_\_fill, const tm \* \_\_tm, const \_CharT \* \_\_beg, const \_CharT \* \_\_end) const

Format and output a time or date. This function formats the data in struct tm according to the provided format string. The format string is interpreted as by strftime().

**Parameters**

*\_\_s* The stream to write to. \
 *\_\_io* Source of locale. \
 *\_\_fill* char\_type to use for padding. \
 *\_\_tm* Struct tm with date and time info to format. \
 *\_\_beg* Start of format string. \
 *\_\_end* End of format string.

**Returns**

Iterator after writing.

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

## Member Data Documentation

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

Numpunct facet id.

## Author

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