首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::time_put

Defined in header <locale>

template< class CharT, class OutputIt = std::ostreambuf_iterator<CharT> > class time_put;

类模板std::time_put封装日期和时间格式规则。I/O机械手std::put_time使用std::time_put对象的I/O流%27s区域设置的方面,以生成std::tm对象。

二次

二次

继承图

类型要求

-输出必须符合输出器的要求。

*。

专门性

标准库提供了两个独立的%28区域独立的%29完全专门化和两个部分专门化:

在标头中定义<locale>

*。

STD:时间[医]放<char>创建日期和时间的窄字符串表示形式。

STD:时间[医]放置<wchar[医]T>创建日期和时间的宽字符串表示形式。

STD:时间[医]PUT<char,OutputIt>使用自定义输出迭代器创建日期和时间的窄字符串表示

STD:时间[医]放置<wchar[医]T,OutputIt>使用自定义输出迭代器创建日期和时间的宽字符串表示形式

此外,在C++程序中构造的每个locale对象都实现了自己的%28 locale特定于这些专门化的%29版本。

成员类型

Member type

Definition

char_type

CharT

iter_type

OutputIt

成员函数

(constructor)

constructs a new time_put facet (public member function)

(destructor)

destructs a time_put facet (protected member function)

put

invokes do_put (public member function)

成员对象

static std::locale::id id

id of the locale (public member object)

受保护成员函数

do_put virtual

formats date/time and writes to output stream (virtual protected member function)

二次

代码语言:javascript
复制
#include <iostream>
#include <ctime>
#include <iomanip>
#include <codecvt>
 
int main()
{
    std::time_t t = std::time(NULL);
    std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv(std::cout.rdbuf());
    std::wostream out(&conv);
    out.imbue(std::locale("ja_JP"));
    // this I/O manipulator std::put_time uses std::time_put<wchar_t>
    out << std::put_time(std::localtime(&t), L"%A %c") << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
水曜日 2011年11月09日 12時32分05秒

二次

另见

time_put_byname

represents the system-supplied std::time_put for the named locale (class template)

time_get

parses time/date values from an input character sequence into struct std::tm (class template)

put_time (C++11)

formats and outputs a date/time value according to the specified format (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券