std::time_get
STD:时间[医]弄到
Defined in header | | |
---|---|---|
template< class CharT, class InputIt = std::istreambuf_iterator<CharT> > class time_get; | | |
类模板std::time_get
封装日期和时间解析规则。I/O机械手std::get_time
使用std::time_get
I/O流%27 s区域设置的方面,以将文本输入转换为std::tm
对象。
二次
二次
继承图
类型要求
-输入必须符合输入器的要求。
*。
专门性
标准库提供了两个独立的%28区域独立的%29完全专门化和两个部分专门化:
在标头中定义<locale>
*。
STD:时间[医]弄到<char>分析日期和时间的窄字符串表示
STD:时间[医]得到<wchar[医]分析日期和时间的宽字符串表示。
STD:时间[医]使用自定义输入迭代器获取<char、InputIt>解析日期和时间的窄字符串表示
STD:时间[医]得到<wchar[医]使用自定义输入迭代器解析日期和时间的宽字符串表示
此外,在C++程序中构造的每个locale对象都实现了自己的%28 locale特定于这些专门化的%29版本。
成员类型
Member type | Definition |
---|---|
char_type | CharT |
iter_type | InputIt |
成员函数
(constructor) | constructs a new time_get facet (public member function) |
---|---|
(destructor) | destructs a time_get facet (protected member function) |
date_order | invokes do_date_order (public member function) |
get_time | invokes do_get_time (public member function) |
get_date | invokes do_get_date (public member function) |
get_weekday | invokes do_get_weekday (public member function) |
get_monthname | invokes do_get_monthname (public member function) |
get_year | invokes do_get_year (public member function) |
get (C++11) | invokes do_get (public member function) |
成员对象
static std::locale::id id | id of the locale (public member object) |
---|
受保护成员函数
do_date_order virtual | obtains preferred ordering of day, month, and year (virtual protected member function) |
---|---|
do_get_time virtual | extracts hours, minutes, and seconds from input stream (virtual protected member function) |
do_get_date virtual | extracts month, day, and year from input stream (virtual protected member function) |
do_get_weekday virtual | extracts the name of a day of the week from input stream (virtual protected member function) |
do_get_monthname virtual | extacts a month name from input stream (virtual protected member function) |
do_get_year virtual | extracts a year from input stream (virtual protected member function) |
do_get virtual | extracts date/time components from input stream, according to the specified format (virtual protected member function) |
从STD::Time继承而来[医]底座
Type | Definition |
---|---|
dateorder | date order enumeration type, defining the values no_order, dmy, mdy, ymd, and ydm |
例
二次
#include <iostream>
#include <sstream>
#include <string>
#include <locale>
#include <ctime>
#include <iomanip>
int main()
{
std::wstring input = L"2011-Februar-18 23:12:34";
std::tm t;
std::wistringstream ss(input
ss.imbue(std::locale("de_DE")
ss >> std::get_time(&t, L"%Y-%b-%d %H:%M:%S" // uses std::time_get<wchar_t>
std::cout << std::asctime(&t
}
二次
产出:
二次
Sun Feb 18 23:12:34 2011
二次
另见
time_put | formats contents of struct std::tm for output as character sequence (class template) |
---|---|
get_time (C++11) | parses a date/time value of specified format (function template) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。