(v0.19-24-g0617ca1 with changes)
#include <OptionsChrono.h>
#include <time.h>
Go to the source code of this file.
|
std::ostream & | operator<< (std::ostream &stream, const clock_type::time_point &t) |
|
std::ostream & | operator<< (std::ostream &stream, const clock_type::duration &dt) |
|
int | main (int argc, const char *argv[]) |
|
◆ clock_type
◆ main()
int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Definition at line 19 of file dateTest.cpp.
26 "timestamp read format",
27 "%Y-%m-%d_%H:%M:%S%z");
29 "timestamp write format",
30 "%Y-%m-%d_%H:%M:%S%z");
32 auto strings = parser.fParse(argc, argv);
36 std::cout << std::chrono::duration_cast<std::chrono::seconds>(t.time_since_epoch()).count() <<
"\n";
38 std::cout <<
" t is " << t <<
"\n";
43 std::cout << std::chrono::duration_cast<std::chrono::seconds>(d).count() <<
"\n";
45 std::cout <<
"dt is " << d <<
"\n";
49 for (
const auto&
string : strings) {
52 strptime(
string.c_str(), readFormat.c_str(), &tmStruct);
53 auto ts = clock_type::time_point(std::chrono::duration_cast<clock_type::duration>(std::chrono::duration<double>(mktime(&tmStruct))));
54 if (readFormat.back() ==
'z') {
55 auto tzStart=
string.find_last_of(
"+-");
56 if (tzStart != std::string::npos) {
57 auto offset = std::stoi(
string.substr(tzStart));
58 ts -= std::chrono::hours(offset/100);
59 ts -= std::chrono::minutes(offset%100);
63 std::cout << std::chrono::duration_cast<std::chrono::seconds>(ts.time_since_epoch()).count() <<
"\n";
65 std::cout <<
"\"" <<
string <<
"\" as time: " << ts <<
"\n";
References options::base::fIsSet(), and quiet.
◆ operator<<() [1/2]
std::ostream& operator<< |
( |
std::ostream & |
stream, |
|
|
const clock_type::duration & |
dt |
|
) |
| |
Definition at line 12 of file dateTest.cpp.
15 stream << std::chrono::duration_cast<std::chrono::duration<double>>(dt).count();
◆ operator<<() [2/2]
std::ostream& operator<< |
( |
std::ostream & |
stream, |
|
|
const clock_type::time_point & |
t |
|
) |
| |
Definition at line 6 of file dateTest.cpp.
9 stream << std::chrono::duration_cast<std::chrono::duration<double>>(t.time_since_epoch()).count();
static options::single< bool > quiet('q', "quiet", "be quiet, no prefix to output lines")