| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 #ifndef V8_DATE_H_ | 5 #ifndef V8_DATE_H_ |
| 6 #define V8_DATE_H_ | 6 #define V8_DATE_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| 11 | 11 |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 class DateCache { | 16 class DateCache { |
| 17 public: | 17 public: |
| 18 static const int kMsPerMin = 60 * 1000; | 18 static const int kMsPerMin = 60 * 1000; |
| 19 static const int kSecPerDay = 24 * 60 * 60; | 19 static const int kSecPerDay = 24 * 60 * 60; |
| 20 static const int64_t kMsPerDay = kSecPerDay * 1000; | 20 static const int64_t kMsPerDay = kSecPerDay * 1000; |
| 21 static const int64_t kMsPerMonth = kMsPerDay * 30; |
| 21 | 22 |
| 22 // The largest time that can be passed to OS date-time library functions. | 23 // The largest time that can be passed to OS date-time library functions. |
| 23 static const int kMaxEpochTimeInSec = kMaxInt; | 24 static const int kMaxEpochTimeInSec = kMaxInt; |
| 24 static const int64_t kMaxEpochTimeInMs = | 25 static const int64_t kMaxEpochTimeInMs = |
| 25 static_cast<int64_t>(kMaxInt) * 1000; | 26 static_cast<int64_t>(kMaxInt) * 1000; |
| 26 | 27 |
| 27 // The largest time that can be stored in JSDate. | 28 // The largest time that can be stored in JSDate. |
| 28 static const int64_t kMaxTimeInMs = | 29 static const int64_t kMaxTimeInMs = |
| 29 static_cast<int64_t>(864000000) * 10000000; | 30 static_cast<int64_t>(864000000) * 10000000; |
| 30 | 31 |
| 31 // Conservative upper bound on time that can be stored in JSDate | 32 // Conservative upper bound on time that can be stored in JSDate |
| 32 // before UTC conversion. | 33 // before UTC conversion. |
| 33 static const int64_t kMaxTimeBeforeUTCInMs = | 34 static const int64_t kMaxTimeBeforeUTCInMs = kMaxTimeInMs + kMsPerMonth; |
| 34 kMaxTimeInMs + 10 * kMsPerDay; | |
| 35 | 35 |
| 36 // Sentinel that denotes an invalid local offset. | 36 // Sentinel that denotes an invalid local offset. |
| 37 static const int kInvalidLocalOffsetInMs = kMaxInt; | 37 static const int kInvalidLocalOffsetInMs = kMaxInt; |
| 38 // Sentinel that denotes an invalid cache stamp. | 38 // Sentinel that denotes an invalid cache stamp. |
| 39 // It is an invariant of DateCache that cache stamp is non-negative. | 39 // It is an invariant of DateCache that cache stamp is non-negative. |
| 40 static const int kInvalidStamp = -1; | 40 static const int kInvalidStamp = -1; |
| 41 | 41 |
| 42 DateCache() : stamp_(0), tz_cache_(base::OS::CreateTimezoneCache()) { | 42 DateCache() : stamp_(0), tz_cache_(base::OS::CreateTimezoneCache()) { |
| 43 ResetDateCache(); | 43 ResetDateCache(); |
| 44 } | 44 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 int ymd_month_; | 273 int ymd_month_; |
| 274 int ymd_day_; | 274 int ymd_day_; |
| 275 | 275 |
| 276 base::TimezoneCache* tz_cache_; | 276 base::TimezoneCache* tz_cache_; |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 } // namespace internal | 279 } // namespace internal |
| 280 } // namespace v8 | 280 } // namespace v8 |
| 281 | 281 |
| 282 #endif | 282 #endif |
| OLD | NEW |