home | help
std::time_put_byname(3)        C++ Standard Libary	 std::time_put_byname(3)

NAME
     std::time_put_byname - std::time_put_byname

Synopsis
	Defined in header <locale>
	template<

	    class CharT,
	    class OutputIt = std::ostreambuf_iterator<CharT>

	> class time_put_byname : public std::time_put<CharT, OutputIt>;

	std::time_put_byname  is  a  std::time_put facet which encapsulates time
     and date
	formatting rules of the locale specified at its construction.

Specializations
	The standard library is guaranteed to provide every specialization  that
     satisfies
	the following type requirements:

	  * CharT is one of char and wchar_t, and
	  * OutputIt must meet the requirements of LegacyOutputIterator.

Member types
	Member type Definition
	char_type   CharT
	iter_type   OutputIt

Member functions
	constructor   constructs a new time_put_byname facet
		      (public member function)
	destructor    destroys a time_put_byname facet
		      (protected member function)

     std::time_put_byname::time_put_byname

	explicit time_put_byname( const char* name, std::size_t refs = 0 );
	explicit  time_put_byname(  const  std::string& name, std::size_t refs =
     (since C++11)
	0 );

	Constructs a new std::time_put_byname facet for a locale with name.

	refs is used for resource management: if refs == 0,  the  implementation
     destroys the
	facet,	when the last std::locale object holding it is destroyed. Other-
     wise, the
	object is not destroyed.

Parameters
	name - the name of the locale
	refs - the number of references that link to the facet

     std::time_put_byname::~time_put_byname

	protected:
	~time_put_byname();

	Destroys the facet.

     Inherited from std::time_put

Member objects
	Member name Type
	id (static) std::locale::id

Member functions
	put invokes do_put
	    (public member function of std::time_put<CharT,OutputIt>)

Protected member functions
	do_put	  formats date/time and writes to output stream
	[virtual] (virtual protected member function of std::time_put<CharT,Out-
     putIt>)

Example
	Prints current time using the "C" locale with  the  time_put  facet  re-
     placed by various
	std::time_put_byname  facets.  The  result  shown was obtained using the
     clang compiler.

     // Run this code

      #include <codecvt>
      #include <ctime>
      #include <iomanip>
      #include <iostream>

      int main()
      {
	  std::time_t t = std::time(nullptr);
	  std::wbuffer_convert<std::codecvt_utf8<wchar_t>>    conv(std::cout.rd-
     buf());
	  std::wostream out(&conv);

	  out.imbue(std::locale(out.getloc(),
				new			       std::time_put_by-
     name<wchar_t>("ja_JP.utf8")));
	  out << std::put_time(std::localtime(&t), L"%A %c") << '\n';

	  out.imbue(std::locale(out.getloc(),
				new			       std::time_put_by-
     name<wchar_t>("ru_RU.utf8")));
	  out << std::put_time(std::localtime(&t), L"%A %c") << '\n';

	  out.imbue(std::locale(out.getloc(),
				new			       std::time_put_by-
     name<wchar_t>("sv_SE.utf8")));
	  out << std::put_time(std::localtime(&t), L"%A %c") << '\n';
      }

Possible output:
      ae"aeaeY 2023a^1'10ae05aeY 19ae44a51c<section>
      Dh<section>Dh<micro>NDh^2Dh<micro>NDh^3  Dh<section>N  05  Dh3/4DhoN  2023
     19:44:51
      torsdag tor  5 okt 2023 19:44:51

See also
	time_put formats contents of std::tm for output as character sequence
		 (class template)

http://cppreference.com 	   2024.06.10		 std::time_put_byname(3)

home | help