Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: base/time.cc

Issue 17802: Inline the TimeDelta::From* construction functions. (Closed)
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/time.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/third_party/nspr/prtime.h" 7 #include "base/third_party/nspr/prtime.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace base { 11 namespace base {
12 12
13 // TimeDelta ------------------------------------------------------------------ 13 // TimeDelta ------------------------------------------------------------------
14 14
15 // static
16 TimeDelta TimeDelta::FromDays(int64 days) {
17 return TimeDelta(days * Time::kMicrosecondsPerDay);
18 }
19
20 // static
21 TimeDelta TimeDelta::FromHours(int64 hours) {
22 return TimeDelta(hours * Time::kMicrosecondsPerHour);
23 }
24
25 // static
26 TimeDelta TimeDelta::FromMinutes(int64 minutes) {
27 return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
28 }
29
30 // static
31 TimeDelta TimeDelta::FromSeconds(int64 secs) {
32 return TimeDelta(secs * Time::kMicrosecondsPerSecond);
33 }
34
35 // static
36 TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
37 return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
38 }
39
40 // static
41 TimeDelta TimeDelta::FromMicroseconds(int64 us) {
42 return TimeDelta(us);
43 }
44
45 int TimeDelta::InDays() const { 15 int TimeDelta::InDays() const {
46 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay); 16 return static_cast<int>(delta_ / Time::kMicrosecondsPerDay);
47 } 17 }
48 18
49 int TimeDelta::InHours() const { 19 int TimeDelta::InHours() const {
50 return static_cast<int>(delta_ / Time::kMicrosecondsPerHour); 20 return static_cast<int>(delta_ / Time::kMicrosecondsPerHour);
51 } 21 }
52 22
53 int TimeDelta::InMinutes() const { 23 int TimeDelta::InMinutes() const {
54 return static_cast<int>(delta_ / Time::kMicrosecondsPerMinute); 24 return static_cast<int>(delta_ / Time::kMicrosecondsPerMinute);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, 86 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE,
117 &result_time); 87 &result_time);
118 if (PR_SUCCESS != result) 88 if (PR_SUCCESS != result)
119 return false; 89 return false;
120 result_time += kTimeTToMicrosecondsOffset; 90 result_time += kTimeTToMicrosecondsOffset;
121 *parsed_time = Time(result_time); 91 *parsed_time = Time(result_time);
122 return true; 92 return true;
123 } 93 }
124 94
125 } // namespace base 95 } // namespace base
OLDNEW
« no previous file with comments | « base/time.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698