public member function
<locale>
std::time_get::get_dateiter_type get_date (iter_type s, iter_type end, ios_base& str, ios_base::iostate& err, tm* t) const;
Read date
Parses the sequence of characters between s and end for a date sequence, and stores its values into the tm object pointed by t.The function reads characters until the character read cannot be part of a valid date sequence expression or end is reached. The next character in the sequence is pointed by the iterator returned by the function.
If successful, the function sets the relevant members of the tm structure t. The remaining members are left unchanged.
Internally, this function simply calls the virtual protected member
do_get_date, which by default parses characters following the same format produced by
"%x"
in
strftime.
The function updates err with the result of the operation if necessary:
- If the format of the sequence is not valid, the function sets
failbit.
- Otherwise, it is unspecified, although some implementations set
errto
eofbitif the function exhausts the sequence of characters (i.e., it reaches
end, both in case of success and failure), or to
goodbitotherwise.
Internally, this function simply calls the virtual protected member
do_get_date, which by default parses characters following the a format that depends on the value returned by member
date_order:
The function updates
errwith the result of the operation if necessary:
- If the format of the sequence is not valid, the function sets
failbit.
- If the function exhausts the sequence of characters (i.e., it reaches
end) during its operations, it sets
eofbit(both
failbitand
eofbitmay be set by a single operation).
- Otherwise, it is unspecified, although some implementations set
errto
goodbit.
[s,end)
, which contains all the characters between s and end, including the character pointed by s but not the character pointed by end.
<ctime>
), whose members are set by a successful call to this member function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// time_get::get_date example
#include <iostream> // std::cout, std::ios
#include <sstream> // std::istringstream
#include <ctime> // std::tm
#include <locale> // std::locale, std::time_get, std::use_facet
int main ()
{
std::locale loc; // classic "C" locale
// get time_get facet:
const std::time_get<char>& tmget = std::use_facet <std::time_get<char> > (loc);
std::ios::iostate state;
std::istringstream iss ("01/02/03");
std::tm when;
tmget.get_date (iss, std::time_get<char>::iter_type(), iss, state, &when);
std::cout << "year: " << when.tm_year << '\n';
std::cout << "month: " << when.tm_mon << '\n';
std::cout << "day: " << when.tm_mday << '\n';
return 0;
}
0
. A value of 3
for tm_year represents the year 1903 (2003 is represented by 103
).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4