OLD | NEW |
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 // Time represents an absolute point in time, internally represented as | 5 // Time represents an absolute point in time, internally represented as |
6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each | 6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each |
7 // platform's epoch, along with other system-dependent clock interface | 7 // platform's epoch, along with other system-dependent clock interface |
8 // routines, is defined in time_PLATFORM.cc. | 8 // routines, is defined in time_PLATFORM.cc. |
9 // | 9 // |
10 // TimeDelta represents a duration of time, internally represented in | 10 // TimeDelta represents a duration of time, internally represented in |
11 // microseconds. | 11 // microseconds. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 us_ += delta.delta_; | 306 us_ += delta.delta_; |
307 return *this; | 307 return *this; |
308 } | 308 } |
309 Time& operator-=(TimeDelta delta) { | 309 Time& operator-=(TimeDelta delta) { |
310 us_ -= delta.delta_; | 310 us_ -= delta.delta_; |
311 return *this; | 311 return *this; |
312 } | 312 } |
313 | 313 |
314 // Return a new time modified by some delta. | 314 // Return a new time modified by some delta. |
315 Time operator+(TimeDelta delta) const { | 315 Time operator+(TimeDelta delta) const { |
316 return Time(us_ + delta.delta_); | 316 return us_ + delta.delta_; |
317 } | 317 } |
318 Time operator-(TimeDelta delta) const { | 318 Time operator-(TimeDelta delta) const { |
319 return Time(us_ - delta.delta_); | 319 return us_ - delta.delta_; |
320 } | 320 } |
321 | 321 |
322 // Comparison operators | 322 // Comparison operators |
323 bool operator==(Time other) const { | 323 bool operator==(Time other) const { |
324 return us_ == other.us_; | 324 return us_ == other.us_; |
325 } | 325 } |
326 bool operator!=(Time other) const { | 326 bool operator!=(Time other) const { |
327 return us_ != other.us_; | 327 return us_ != other.us_; |
328 } | 328 } |
329 bool operator<(Time other) const { | 329 bool operator<(Time other) const { |
(...skipping 13 matching lines...) Expand all Loading... |
343 friend class TimeDelta; | 343 friend class TimeDelta; |
344 | 344 |
345 // Explodes the given time to either local time |is_local = true| or UTC | 345 // Explodes the given time to either local time |is_local = true| or UTC |
346 // |is_local = false|. | 346 // |is_local = false|. |
347 void Explode(bool is_local, Exploded* exploded) const; | 347 void Explode(bool is_local, Exploded* exploded) const; |
348 | 348 |
349 // Unexplodes a given time assuming the source is either local time | 349 // Unexplodes a given time assuming the source is either local time |
350 // |is_local = true| or UTC |is_local = false|. | 350 // |is_local = true| or UTC |is_local = false|. |
351 static Time FromExploded(bool is_local, const Exploded& exploded); | 351 static Time FromExploded(bool is_local, const Exploded& exploded); |
352 | 352 |
353 explicit Time(int64 us) : us_(us) { | 353 Time(int64 us) : us_(us) { |
354 } | 354 } |
355 | 355 |
356 // The representation of Jan 1, 1970 UTC in microseconds since the | 356 // The representation of Jan 1, 1970 UTC in microseconds since the |
357 // platform-dependent epoch. | 357 // platform-dependent epoch. |
358 static const int64 kTimeTToMicrosecondsOffset; | 358 static const int64 kTimeTToMicrosecondsOffset; |
359 | 359 |
360 // Time in microseconds in UTC. | 360 // Time in microseconds in UTC. |
361 int64 us_; | 361 int64 us_; |
362 }; | 362 }; |
363 | 363 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 #endif | 491 #endif |
492 }; | 492 }; |
493 | 493 |
494 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 494 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
495 return TimeTicks(t.ticks_ + delta_); | 495 return TimeTicks(t.ticks_ + delta_); |
496 } | 496 } |
497 | 497 |
498 } // namespace base | 498 } // namespace base |
499 | 499 |
500 #endif // BASE_TIME_H_ | 500 #endif // BASE_TIME_H_ |
OLD | NEW |