OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/time.h" | 5 #include "base/time.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "base/third_party/nspr/prtime.h" | 8 #include "base/third_party/nspr/prtime.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 double TimeDelta::InMillisecondsF() const { | 36 double TimeDelta::InMillisecondsF() const { |
37 return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond; | 37 return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond; |
38 } | 38 } |
39 | 39 |
40 int64 TimeDelta::InMilliseconds() const { | 40 int64 TimeDelta::InMilliseconds() const { |
41 return delta_ / Time::kMicrosecondsPerMillisecond; | 41 return delta_ / Time::kMicrosecondsPerMillisecond; |
42 } | 42 } |
43 | 43 |
| 44 int64 TimeDelta::InMillisecondsRoundedUp() const { |
| 45 return (delta_ + Time::kMicrosecondsPerMillisecond - 1) / |
| 46 Time::kMicrosecondsPerMillisecond; |
| 47 } |
| 48 |
44 int64 TimeDelta::InMicroseconds() const { | 49 int64 TimeDelta::InMicroseconds() const { |
45 return delta_; | 50 return delta_; |
46 } | 51 } |
47 | 52 |
48 // Time ----------------------------------------------------------------------- | 53 // Time ----------------------------------------------------------------------- |
49 | 54 |
50 // static | 55 // static |
51 Time Time::FromTimeT(time_t tt) { | 56 Time Time::FromTimeT(time_t tt) { |
52 if (tt == 0) | 57 if (tt == 0) |
53 return Time(); // Preserve 0 so we can tell it doesn't exist. | 58 return Time(); // Preserve 0 so we can tell it doesn't exist. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, | 99 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, |
95 &result_time); | 100 &result_time); |
96 if (PR_SUCCESS != result) | 101 if (PR_SUCCESS != result) |
97 return false; | 102 return false; |
98 result_time += kTimeTToMicrosecondsOffset; | 103 result_time += kTimeTToMicrosecondsOffset; |
99 *parsed_time = Time(result_time); | 104 *parsed_time = Time(result_time); |
100 return true; | 105 return true; |
101 } | 106 } |
102 | 107 |
103 } // namespace base | 108 } // namespace base |
OLD | NEW |