1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/base/trivial_clock_traits.h"
6
7 namespace openscreen {
8
operator <<(std::ostream & os,const TrivialClockTraits::duration & d)9 std::ostream& operator<<(std::ostream& os,
10 const TrivialClockTraits::duration& d) {
11 constexpr char kUnits[] = " \u03BCs"; // Greek Mu + "s"
12 return os << d.count() << kUnits;
13 }
14
operator <<(std::ostream & os,const TrivialClockTraits::time_point & tp)15 std::ostream& operator<<(std::ostream& os,
16 const TrivialClockTraits::time_point& tp) {
17 constexpr char kUnits[] = " \u03BCs-ticks"; // Greek Mu + "s-ticks"
18 return os << tp.time_since_epoch().count() << kUnits;
19 }
20
operator <<(std::ostream & out,const std::chrono::hours & hrs)21 std::ostream& operator<<(std::ostream& out, const std::chrono::hours& hrs) {
22 return (out << hrs.count() << " hours");
23 }
24
operator <<(std::ostream & out,const std::chrono::minutes & mins)25 std::ostream& operator<<(std::ostream& out, const std::chrono::minutes& mins) {
26 return (out << mins.count() << " minutes");
27 }
28
operator <<(std::ostream & out,const std::chrono::seconds & secs)29 std::ostream& operator<<(std::ostream& out, const std::chrono::seconds& secs) {
30 return (out << secs.count() << " seconds");
31 }
32
operator <<(std::ostream & out,const std::chrono::milliseconds & millis)33 std::ostream& operator<<(std::ostream& out,
34 const std::chrono::milliseconds& millis) {
35 return (out << millis.count() << " ms");
36 }
37
38 } // namespace openscreen
39