std::put_time
cppreference.com
[] |
Google. . , . , . |
<metanoindex/>
<tbody> </tbody> template< class charT > /*unspecified*/ put_time( const std::tm* tmb, const charT* fmt); |
( C++11) | |
out << put_time(tmb, fmt), tmb fmt , std::strftime, std::wcsftime, ( CharT), std::time_put out.:
When used in an expression
out << put_time(tmb, fmt), converts the date and time information from a given calendar time tmb to a character string according to format string fmt, as if by calling std::strftime, std::wcsftime, or analog (depending on CharT), according to the std::time_put facet of the locale currently imbued in the output stream out. .
| tmb | , () gmtime ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt | , .
(
: pointer to a null-terminated CharT string specifying the format of conversion.
(
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
,
out std::basic_ostream<CharT, Traits>, out << put_time(tmb, fmt) :
Returns an object of unspecified type such that if
out is the name of an output stream of type std::basic_ostream<CharT, Traits>, then the expression out << put_time(tmb, fmt) behaves as if the following code was executed:typedef std::ostreambuf_iterator<CharT, Traits> Iter; typedef std::time_put<CharT, Iter> TimePut; const TimePut& tp = std::use_facet<TimePut>(out.getloc()); const Iter end = tp.put(Iter(out.rdbuf()), out, out.fill(), tmb, fmt, fmt + Traits::length(fmt)); if (end.failed()) out.setstate(std::ios_base::badbit);
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
std::time_t t = std::time(NULL);
std::tm tm = *std::localtime(&t);
std::cout.imbue(std::locale("ru_RU.utf8"));
std::cout << "ru_RU: " << std::put_time(&tm, "%c %Z") << '\n';
std::cout.imbue(std::locale("ja_JP.utf8"));
std::cout << "ja_JP: " << std::put_time(&tm, "%c %Z") << '\n';
}
:
ru_RU: . 28 . 2011 10:21:16 EST
ja_JP: 20111228 102116 EST
.
| std::tm ( ) | |
| std::tm () | |
| std::tm () |