| OLD | NEW |
| 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 // Time represents an absolute point in coordinated universal time (UTC), | 5 // Time represents an absolute point in coordinated universal time (UTC), |
| 6 // internally represented as microseconds (s/1,000,000) since the Windows epoch | 6 // internally represented as microseconds (s/1,000,000) since the Windows epoch |
| 7 // (1601-01-01 00:00:00 UTC) (See http://crbug.com/14734). System-dependent | 7 // (1601-01-01 00:00:00 UTC) (See http://crbug.com/14734). System-dependent |
| 8 // clock interface routines are defined in time_PLATFORM.cc. | 8 // clock interface routines are 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 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond * | 225 static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond * |
| 226 kMillisecondsPerSecond; | 226 kMillisecondsPerSecond; |
| 227 static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60; | 227 static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60; |
| 228 static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60; | 228 static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60; |
| 229 static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24; | 229 static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24; |
| 230 static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7; | 230 static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7; |
| 231 static const int64 kNanosecondsPerMicrosecond = 1000; | 231 static const int64 kNanosecondsPerMicrosecond = 1000; |
| 232 static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond * | 232 static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond * |
| 233 kMicrosecondsPerSecond; | 233 kMicrosecondsPerSecond; |
| 234 | 234 |
| 235 // The representation of Jan 1, 1970 UTC in microseconds since the |
| 236 // platform-dependent epoch. |
| 237 static const int64 kTimeTToMicrosecondsOffset; |
| 238 |
| 235 #if !defined(OS_WIN) | 239 #if !defined(OS_WIN) |
| 236 // On Mac & Linux, this value is the delta from the Windows epoch of 1601 to | 240 // On Mac & Linux, this value is the delta from the Windows epoch of 1601 to |
| 237 // the Posix delta of 1970. This is used for migrating between the old | 241 // the Posix delta of 1970. This is used for migrating between the old |
| 238 // 1970-based epochs to the new 1601-based ones. It should be removed from | 242 // 1970-based epochs to the new 1601-based ones. It should be removed from |
| 239 // this global header and put in the platform-specific ones when we remove the | 243 // this global header and put in the platform-specific ones when we remove the |
| 240 // migration code. | 244 // migration code. |
| 241 static const int64 kWindowsEpochDeltaMicroseconds; | 245 static const int64 kWindowsEpochDeltaMicroseconds; |
| 242 #else | 246 #else |
| 243 // To avoid overflow in QPC to Microseconds calculations, since we multiply | 247 // To avoid overflow in QPC to Microseconds calculations, since we multiply |
| 244 // by kMicrosecondsPerSecond, then the QPC value should not exceed | 248 // by kMicrosecondsPerSecond, then the QPC value should not exceed |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // An example of a time string which is converted is as below:- | 489 // An example of a time string which is converted is as below:- |
| 486 // "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified | 490 // "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified |
| 487 // in the input string, local time |is_local = true| or | 491 // in the input string, local time |is_local = true| or |
| 488 // UTC |is_local = false| is assumed. A timezone that cannot be parsed | 492 // UTC |is_local = false| is assumed. A timezone that cannot be parsed |
| 489 // (e.g. "UTC" which is not specified in RFC822) is treated as if the | 493 // (e.g. "UTC" which is not specified in RFC822) is treated as if the |
| 490 // timezone is not specified. | 494 // timezone is not specified. |
| 491 static bool FromStringInternal(const char* time_string, | 495 static bool FromStringInternal(const char* time_string, |
| 492 bool is_local, | 496 bool is_local, |
| 493 Time* parsed_time); | 497 Time* parsed_time); |
| 494 | 498 |
| 495 // The representation of Jan 1, 1970 UTC in microseconds since the | |
| 496 // platform-dependent epoch. | |
| 497 static const int64 kTimeTToMicrosecondsOffset; | |
| 498 | |
| 499 // Time in microseconds in UTC. | 499 // Time in microseconds in UTC. |
| 500 int64 us_; | 500 int64 us_; |
| 501 }; | 501 }; |
| 502 | 502 |
| 503 // Inline the TimeDelta factory methods, for fast TimeDelta construction. | 503 // Inline the TimeDelta factory methods, for fast TimeDelta construction. |
| 504 | 504 |
| 505 // static | 505 // static |
| 506 inline TimeDelta TimeDelta::FromDays(int days) { | 506 inline TimeDelta TimeDelta::FromDays(int days) { |
| 507 // Preserve max to prevent overflow. | 507 // Preserve max to prevent overflow. |
| 508 if (days == std::numeric_limits<int>::max()) | 508 if (days == std::numeric_limits<int>::max()) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 734 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
| 735 return TimeTicks(t.ticks_ + delta_); | 735 return TimeTicks(t.ticks_ + delta_); |
| 736 } | 736 } |
| 737 | 737 |
| 738 // For logging use only. | 738 // For logging use only. |
| 739 BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks); | 739 BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks); |
| 740 | 740 |
| 741 } // namespace base | 741 } // namespace base |
| 742 | 742 |
| 743 #endif // BASE_TIME_TIME_H_ | 743 #endif // BASE_TIME_TIME_H_ |
| OLD | NEW |