public member function
<locale>
std::time_put::putiter_type put (iter_type s, ios_base& str, char_type fill, const tm* t, const char_type* pattern, const char_type* pat_end) const;iter_type put (iter_type s, ios_base& str, char_type fill, const tm* t, char format, char modifier = 0) const;
Write time and date
Formats the time value in the tm structure pointed by t into a sequence of characters.The function writes the characters resulting from the formatting operation into the sequence whose first character is pointed by s.
An iterator to the character right after the last element written to the output sequence is returned by the function.
'%'
) followed by argument format, with modifier optionally inserted in between (when not equal to zero).
[fmt_begin,fmt_end)
sequentially replacing any format specifier (as if recognized by the C function strftime) by the result of calling the virtual protected member do_put with the proper arguments (with the specifier being replaced and, optionally, its modifier, as final arguments).
The function uses the ctype facet of str's locale to narrow the characters in the sequence to char
when necessary.
<ctime>
), whose data is formatted.
[pattern,pat_end)
, which contains all the characters between pattern and pat_end, including the character pointed by pattern but not the character pointed by pat_end.
0
('\0'
) is interpreted as no modifier.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// time_put example
// time_put::put example
#include <iostream> // std::cout
#include <string> // std::string
#include <ctime> // std::time, std::localtime, std::tm, std::time_t
#include <locale> // std::locale, std::time_put, std::use_facet
int main ()
{
std::locale loc; // classic "C" locale
// get time_put facet:
const std::time_put<char>& tmput = std::use_facet <std::time_put<char> > (loc);
std::time_t timestamp;
std::time ( ×tamp );
std::tm * now = std::localtime ( ×tamp );
// using pattern string:
std::string pattern ("Now it's: %I:%M%p\n");
tmput.put (std::cout, std::cout, ' ', now, pattern.data(), pattern.data()+pattern.length());
// using single specifier:
std::cout << "Now it's: ";
tmput.put (std::cout, std::cout, ' ', now, 'X');
std::cout << '\n';
return 0;
}
Now it's: 12:29PM Now it's: 12:29:08
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