在线文档教程
C++
本土化 | Localizations

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_getI/O流%27 s区域设置的方面,以将文本输入转换为std::tm对象。

二次

二次

继承图

类型要求

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

*。

专门性

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

在标头中定义<locale>

*。

STD:时间[医]弄到<char>分析日期和时间的窄字符串表示

STD:时间[医]得到<wchar[医]分析日期和时间的宽字符串表示。

STD:时间[医]使用自定义输入迭代器获取<char、InputIt>解析日期和时间的窄字符串表示

STD:时间[医]得到<wchar[医]使用自定义输入迭代器解析日期和时间的宽字符串表示

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

成员类型

Member typeDefinition
char_typeCharT
iter_typeInputIt

成员函数

(constructor)constructs a new time_get facet (public member function)
(destructor)destructs a time_get facet (protected member function)
date_orderinvokes do_date_order (public member function)
get_timeinvokes do_get_time (public member function)
get_dateinvokes do_get_date (public member function)
get_weekdayinvokes do_get_weekday (public member function)
get_monthnameinvokes do_get_monthname (public member function)
get_yearinvokes do_get_year (public member function)
get (C++11)invokes do_get (public member function)

成员对象

static std::locale::id idid of the locale (public member object)

受保护成员函数

do_date_order virtualobtains preferred ordering of day, month, and year (virtual protected member function)
do_get_time virtualextracts hours, minutes, and seconds from input stream (virtual protected member function)
do_get_date virtualextracts month, day, and year from input stream (virtual protected member function)
do_get_weekday virtualextracts the name of a day of the week from input stream (virtual protected member function)
do_get_monthname virtualextacts a month name from input stream (virtual protected member function)
do_get_year virtualextracts a year from input stream (virtual protected member function)
do_get virtualextracts date/time components from input stream, according to the specified format (virtual protected member function)

从STD::Time继承而来[医]底座

TypeDefinition
dateorderdate 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_putformats 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。

http://en.cppreference.com/w/cpp/locale/time[医]弄到