Name

time_put class template — Facet for output of dates and times

Synopsis

template <typename charT, typename OutputIterator = ostreambuf_iterator<charT> >
class time_put : public locale::facet
{
public:
  typedef charT char_type;
  typedef OutputIterator iter_type;
  explicit time_put(size_t refs = 0);
  iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb,
                const charT* pattern, const charT* pat_end) const;
  iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb,
                char format, char modifier = 0) const;
  static locale::id id;
protected:
  virtual ~time_put(  );
  virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t,
                           char format, char modifier) const;
};

The time_put class template is a facet for formatting and writing dates and times. The time_put<char> and time_put<wchar_t> instantiations are standard.

Note that time_put is unlike other facets. The public put function does not always directly call do_put. Here are the complete descriptions of put and do_put:

iter_type put (iter_type out, ios_base& stream, char_type fill, const tm* t, const charT* pattern, const charT* pat_end) const

Reads the pattern in [pattern, pat_end) and writes formatted date and time information to out. The pattern contains ordinary characters (which are written directly to out) interspersed with format specifiers. A format specifier starts with '%' and is followed by an optional modifier character, which is followed in turn by a format specifier character. The put function checks format characters by first calling narrow from the ctype<charT> facet, then checking the narrowed character.

For each format specifier, put calls do_put(out, stream, fill, t, format, modifier), in which format is the format specifier and modifier is the modifier character or 0 if no modifier is present.

See Also

The use of modifier characters is implementation-defined. The standard does not define any modifiers. See the do_put member function for more information.

iter_type put (iter_type out, ios_base& stream, char_type fill, const tm* t, char format, char modifier = 0) const

Returns do_put(out, stream, fill, t, format, modifier).

virtual iter_type do_put (iter_type out, ios_base& stream, char_type fill, const tm* t, char format, char modifier) const

Formats a single date or time element and writes the formatted characters to out. The format character specifies what to output (as shown in Table 13-22). The date and time information is obtained from t.

The do_put function, unlike some of the other output facets, does not use stream's flags or field width. The fill parameter is used by implementation-defined formatting.