18inline std::string
to_string(
const std::time_t & time )
20 std::ostringstream os;
26template<
typename Clock,
typename Duration =
typename Clock::duration >
27std::string
to_string(
const std::chrono::time_point< Clock, Duration > & tp )
29 auto in_time_t = std::chrono::system_clock::to_time_t( tp );
34template<
typename Rep,
typename Period = std::ratio< 1 > >
35std::string
to_string(
const std::chrono::duration< Rep, Period > & duration )
37 auto seconds_as_int = std::chrono::duration_cast< std::chrono::seconds >( duration );
38 if( seconds_as_int == duration )
39 return std::to_string( seconds_as_int.count() ) +
"s";
40 auto seconds_as_double = std::chrono::duration_cast< std::chrono::duration< double > >( duration );
41 std::ostringstream os;
42 os << seconds_as_double.count();
48template<
typename Clock,
typename Duration =
typename Clock::duration >
49std::ostream &
operator<<( std::ostream & o,
const std::chrono::time_point< Clock, Duration > & tp )
55template<
typename Rep,
typename Period = std::ratio< 1 > >
56std::ostream &
operator<<( std::ostream & o,
const std::chrono::duration< Rep, Period > & duration )
std::ostream & operator<<(std::ostream &o, const std::chrono::time_point< Clock, Duration > &tp)
Definition: chrono.h:49
std::string to_string(const std::time_t &time)
Definition: chrono.h:18