OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 // Resist the urge to make the output of these fancy. They are just for | |
6 // debugging. | |
7 | |
8 #include "base/time/time_logging.h" | |
9 | |
10 #include <iostream> | |
11 | |
12 #include "base/strings/stringprintf.h" | |
13 #include "base/time/time.h" | |
14 | |
15 namespace base { | |
16 | |
17 std::ostream& operator<<(std::ostream& os, const TimeDelta& time_delta) { | |
18 return os << time_delta.InSecondsF() << "s"; | |
19 } | |
20 | |
21 std::ostream& operator<<(std::ostream& os, const Time& time) { | |
22 Time::Exploded e; | |
mmenke
2014/10/21 14:20:09
nit: Google style guide strong discourages using
Adam Rice
2014/10/23 01:13:02
Done.
| |
23 time.UTCExplode(&e); | |
24 // Use StringPrintf because iostreams formatting is painful. | |
25 return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", | |
26 e.year, | |
27 e.month, | |
28 e.day_of_month, | |
29 e.hour, | |
30 e.minute, | |
31 e.second, | |
32 e.millisecond); | |
33 } | |
34 | |
35 std::ostream& operator<<(std::ostream& os, const TimeTicks& time_ticks) { | |
36 // This function formats a TimeTicks object as if it was a Time object. | |
37 const Time as_time = | |
38 Time::UnixEpoch() + (time_ticks - TimeTicks::UnixEpoch()); | |
39 return os << as_time; | |
40 } | |
41 | |
42 } // namespace base | |
OLD | NEW |