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

Side by Side Diff: base/time.cc

Issue 179028: Revert "Fix a ton of compiler warnings." (Closed)
Patch Set: Created 11 years, 3 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') | base/time_posix.cc » ('j') | 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) 2009 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/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"
11 11
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 int64 TimeDelta::InMicroseconds() const { 44 int64 TimeDelta::InMicroseconds() const {
45 return delta_; 45 return delta_;
46 } 46 }
47 47
48 // Time ----------------------------------------------------------------------- 48 // Time -----------------------------------------------------------------------
49 49
50 // static 50 // static
51 Time Time::FromTimeT(time_t tt) { 51 Time Time::FromTimeT(time_t tt) {
52 if (tt == 0) 52 if (tt == 0)
53 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.
54 return Time((tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset); 54 return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset;
55 } 55 }
56 56
57 time_t Time::ToTimeT() const { 57 time_t Time::ToTimeT() const {
58 if (us_ == 0) 58 if (us_ == 0)
59 return 0; // Preserve 0 so we can tell it doesn't exist. 59 return 0; // Preserve 0 so we can tell it doesn't exist.
60 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond; 60 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
61 } 61 }
62 62
63 // static 63 // static
64 Time Time::FromDoubleT(double dt) { 64 Time Time::FromDoubleT(double dt) {
65 return Time(static_cast<int64>((dt * 65 return (dt * static_cast<double>(kMicrosecondsPerSecond)) +
66 static_cast<double>(kMicrosecondsPerSecond)) + 66 kTimeTToMicrosecondsOffset;
67 kTimeTToMicrosecondsOffset));
68 } 67 }
69 68
70 double Time::ToDoubleT() const { 69 double Time::ToDoubleT() const {
71 if (us_ == 0) 70 if (us_ == 0)
72 return 0; // Preserve 0 so we can tell it doesn't exist. 71 return 0; // Preserve 0 so we can tell it doesn't exist.
73 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) / 72 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) /
74 static_cast<double>(kMicrosecondsPerSecond)); 73 static_cast<double>(kMicrosecondsPerSecond));
75 } 74 }
76 75
77 Time Time::LocalMidnight() const { 76 Time Time::LocalMidnight() const {
(...skipping 16 matching lines...) Expand all
94 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, 93 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE,
95 &result_time); 94 &result_time);
96 if (PR_SUCCESS != result) 95 if (PR_SUCCESS != result)
97 return false; 96 return false;
98 result_time += kTimeTToMicrosecondsOffset; 97 result_time += kTimeTToMicrosecondsOffset;
99 *parsed_time = Time(result_time); 98 *parsed_time = Time(result_time);
100 return true; 99 return true;
101 } 100 }
102 101
103 } // namespace base 102 } // namespace base
OLDNEW
« no previous file with comments | « base/time.h ('k') | base/time_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698