[DEV] add steady clock display

This commit is contained in:
Edouard DUPIN 2015-04-13 22:08:35 +02:00
parent b16d915a45
commit 4b9c5e573f
2 changed files with 16 additions and 0 deletions

View File

@ -1395,4 +1395,19 @@ namespace std {
_os << year << "y " << day << "d " << hour << "h" << minute << ":"<< second << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns"; _os << year << "y " << day << "d " << hour << "h" << minute << ":"<< second << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns";
return _os; return _os;
} }
std::ostream& operator <<(std::ostream& _os, const std11::chrono::steady_clock::time_point& _obj) {
std11::chrono::nanoseconds ns = std11::chrono::duration_cast<std11::chrono::nanoseconds>(_obj.time_since_epoch());
int64_t totalSecond = ns.count()/1000000000;
int64_t millisecond = (ns.count()%1000000000)/1000000;
int64_t microsecond = (ns.count()%1000000)/1000;
int64_t nanosecond = ns.count()%1000;
//_os << totalSecond << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns";
int32_t second = totalSecond % 60;
int32_t minute = (totalSecond/60)%60;
int32_t hour = (totalSecond/3600)%24;
int32_t day = (totalSecond/(24*3600))%365;
int32_t year = totalSecond/(24*3600*365);
_os << year << "y " << day << "d " << hour << "h" << minute << ":"<< second << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns";
return _os;
}
} }

View File

@ -559,6 +559,7 @@ namespace std {
std::ostream& operator <<(std::ostream& _os, const std::vector<uint8_t>& _obj); std::ostream& operator <<(std::ostream& _os, const std::vector<uint8_t>& _obj);
std::ostream& operator <<(std::ostream& _os, const std11::chrono::system_clock::time_point& _obj); std::ostream& operator <<(std::ostream& _os, const std11::chrono::system_clock::time_point& _obj);
std::ostream& operator <<(std::ostream& _os, const std11::chrono::steady_clock::time_point& _obj);
}; };