std::time_get
<locale>
class CharT,
class InputIt = std::istreambuf_iterator <CharT>
Class template std::time_get
encapsulates date and time parsing rules. The I/O manipulator std::get_time uses the std::time_get
facet of the I/O stream's locale to convert text input to a std::tm object.
Inheritance diagram
If a std::time_get
specialization is not guaranteed to be provided by the standard library (see below), the behaviors of its member functions (except the constructor and destructor) are not guaranteed as specified.
Contents
[edit] Specializations
The standard library is guaranteed to provide the following specializations (they are required to be implemented by any locale object):
<locale>
In addition, the standard library is also guaranteed to provide every specialization that satisfies the following type requirements:
-
CharT
is one of char and wchar_t, and -
InputIt
must meet the requirements of LegacyInputIterator.
[edit] Nested types
char_type
CharT
iter_type
InputIt
[edit] Data members
[edit] Member functions
[edit] Protected member functions
(virtual protected member function) [edit]
(virtual protected member function) [edit]
(virtual protected member function) [edit]
(virtual protected member function) [edit]
(virtual protected member function) [edit]
Inherited from std::time_base
Nested types
dateorder
date order enumeration type, defining the values no_order
, dmy
, mdy
, ymd
, and ydm
[edit] Example
Note: choose clang to observe the output. libstdc++ does not correctly implement the %b specifier: bug 78714.
#include <iomanip> #include <iostream> #include <locale> #include <sstream> int main() { std::tm t = {}; std::istringstream ss("2011-Februar-18 23:12:34"); ss.imbue(std::locale ("de_DE.utf-8")); ss >> std::get_time (&t, "%Y-%b-%d %H:%M:%S"); if (ss.fail()) std::cout << "Parse failed\n"; else std::cout << std::put_time (&t, "%c") << '\n'; }
Possible output:
Sun Feb 18 23:12:34 2011