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

Side by Side Diff: base/time/time.cc

Issue 1076443002: Removed obsolete float_util.h as VS2013 supports standards well enough. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed mistake in value converter. Created 5 years, 8 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/json/json_parser.cc ('k') | base/trace_event/trace_event_impl.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/time.h" 5 #include "base/time/time.h"
6 6
7 #include <cmath>
7 #include <ios> 8 #include <ios>
8 #include <limits> 9 #include <limits>
9 #include <ostream> 10 #include <ostream>
10 #include <sstream> 11 #include <sstream>
11 12
12 #include "base/float_util.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/third_party/nspr/prtime.h" 16 #include "base/third_party/nspr/prtime.h"
17 17
18 namespace base { 18 namespace base {
19 19
20 // TimeDelta ------------------------------------------------------------------ 20 // TimeDelta ------------------------------------------------------------------
21 21
22 // static 22 // static
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (std::numeric_limits<int64>::max() - kTimeTToMicrosecondsOffset <= us_) { 154 if (std::numeric_limits<int64>::max() - kTimeTToMicrosecondsOffset <= us_) {
155 DLOG(WARNING) << "Overflow when converting base::Time with internal " << 155 DLOG(WARNING) << "Overflow when converting base::Time with internal " <<
156 "value " << us_ << " to time_t."; 156 "value " << us_ << " to time_t.";
157 return std::numeric_limits<time_t>::max(); 157 return std::numeric_limits<time_t>::max();
158 } 158 }
159 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond; 159 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
160 } 160 }
161 161
162 // static 162 // static
163 Time Time::FromDoubleT(double dt) { 163 Time Time::FromDoubleT(double dt) {
164 if (dt == 0 || IsNaN(dt)) 164 if (dt == 0 || std::isnan(dt))
165 return Time(); // Preserve 0 so we can tell it doesn't exist. 165 return Time(); // Preserve 0 so we can tell it doesn't exist.
166 if (dt == std::numeric_limits<double>::infinity()) 166 if (dt == std::numeric_limits<double>::infinity())
167 return Max(); 167 return Max();
168 return Time(static_cast<int64>((dt * 168 return Time(static_cast<int64>((dt *
169 static_cast<double>(kMicrosecondsPerSecond)) + 169 static_cast<double>(kMicrosecondsPerSecond)) +
170 kTimeTToMicrosecondsOffset)); 170 kTimeTToMicrosecondsOffset));
171 } 171 }
172 172
173 double Time::ToDoubleT() const { 173 double Time::ToDoubleT() const {
174 if (is_null()) 174 if (is_null())
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return is_in_range(month, 1, 12) && 337 return is_in_range(month, 1, 12) &&
338 is_in_range(day_of_week, 0, 6) && 338 is_in_range(day_of_week, 0, 6) &&
339 is_in_range(day_of_month, 1, 31) && 339 is_in_range(day_of_month, 1, 31) &&
340 is_in_range(hour, 0, 23) && 340 is_in_range(hour, 0, 23) &&
341 is_in_range(minute, 0, 59) && 341 is_in_range(minute, 0, 59) &&
342 is_in_range(second, 0, 60) && 342 is_in_range(second, 0, 60) &&
343 is_in_range(millisecond, 0, 999); 343 is_in_range(millisecond, 0, 999);
344 } 344 }
345 345
346 } // namespace base 346 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_parser.cc ('k') | base/trace_event/trace_event_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698