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 | |
49 int64 TimeDelta::InMicroseconds() const { | 44 int64 TimeDelta::InMicroseconds() const { |
50 return delta_; | 45 return delta_; |
51 } | 46 } |
52 | 47 |
53 // Time ----------------------------------------------------------------------- | 48 // Time ----------------------------------------------------------------------- |
54 | 49 |
55 // static | 50 // static |
56 Time Time::FromTimeT(time_t tt) { | 51 Time Time::FromTimeT(time_t tt) { |
57 if (tt == 0) | 52 if (tt == 0) |
58 return Time(); // Preserve 0 so we can tell it doesn't exist. | 53 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... |
99 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, | 94 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, |
100 &result_time); | 95 &result_time); |
101 if (PR_SUCCESS != result) | 96 if (PR_SUCCESS != result) |
102 return false; | 97 return false; |
103 result_time += kTimeTToMicrosecondsOffset; | 98 result_time += kTimeTToMicrosecondsOffset; |
104 *parsed_time = Time(result_time); | 99 *parsed_time = Time(result_time); |
105 return true; | 100 return true; |
106 } | 101 } |
107 | 102 |
108 } // namespace base | 103 } // namespace base |
OLD | NEW |