Type for time. Converts to time_point and string.
More...
#include <types_easy.hpp>
|
| operator const system_clock::time_point () const |
|
| operator const string () const |
| Returns local time as string in ISO 8601 format (FTTz). More...
|
|
const string | strtime (const string &format, const bool &local=true) const |
| Converts time to a string. More...
|
|
|
system_clock::time_point | timepoint = system_clock::time_point() |
|
Type for time. Converts to time_point and string.
- Since
- 0.100.0
◆ operator const string()
Mastodon::Easy::time_type::operator const string |
( |
| ) |
const |
Returns local time as string in ISO 8601 format (FTTz).
- Since
- 0.100.0
30 return strtime(
"%FT%T%z",
true);
const string strtime(const string &format, const bool &local=true) const
Converts time to a string.
Definition: types_easy.cpp:33
◆ strtime()
const string Mastodon::Easy::time_type::strtime |
( |
const string & |
format, |
|
|
const bool & |
local = true |
|
) |
| const |
Converts time to a string.
The return value can not exceed 1023 chars.
- Parameters
-
format | The format of the string, same as with strftime . |
local | Use local time (default) or UTC. |
Example:
std::cout << timepoint.
strtime(
"%F, %T UTC",
false) <<
'\n';
- Returns
- The time as string.
- Since
- 0.100.0
- Examples
- example02_stream.cpp.
35 constexpr std::uint16_t bufsize = 1024;
36 std::time_t time = system_clock::to_time_t(timepoint);
40 tm = std::localtime(&time);
44 tm = std::gmtime(&time);
48 std::strftime(buffer, bufsize, format.c_str(), tm);
50 return static_cast<const string>(buffer);
◆ operator<<
Returns local time as string in ISO 8601 format (FTTz).
- Since
- 0.100.0
The documentation for this struct was generated from the following files: