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 #include "src/date.h" | 5 #include "src/date.h" |
6 | 6 |
7 #include "src/objects.h" | 7 #include "src/objects.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 | 9 |
10 #ifdef V8_I18N_SUPPORT | |
11 #include "src/i18n.h" | |
12 #endif | |
13 | |
10 namespace v8 { | 14 namespace v8 { |
11 namespace internal { | 15 namespace internal { |
12 | 16 |
13 | 17 |
14 static const int kDaysIn4Years = 4 * 365 + 1; | 18 static const int kDaysIn4Years = 4 * 365 + 1; |
15 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; | 19 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; |
16 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; | 20 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; |
17 static const int kDays1970to2000 = 30 * 365 + 7; | 21 static const int kDays1970to2000 = 30 * 365 + 7; |
18 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - | 22 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - |
19 kDays1970to2000; | 23 kDays1970to2000; |
20 static const int kYearsOffset = 400000; | 24 static const int kYearsOffset = 400000; |
21 static const char kDaysInMonths[] = | 25 static const char kDaysInMonths[] = |
22 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 26 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
23 | 27 |
28 DateCache::DateCache() | |
29 : stamp_(0), | |
30 tz_cache_( | |
31 #ifdef V8_I18N_SUPPORT | |
32 FLAG_icu_timezone_data ? new ICUOSTimezoneCache() : | |
ulan
2017/03/03 13:20:27
nit: let's keep the conditionals properly nested.
Dan Ehrenberg
2017/03/03 15:06:54
Done.
| |
33 #endif | |
34 base::OS::CreateTimezoneCache()) { | |
35 ResetDateCache(); | |
36 } | |
24 | 37 |
25 void DateCache::ResetDateCache() { | 38 void DateCache::ResetDateCache() { |
26 static const int kMaxStamp = Smi::kMaxValue; | 39 static const int kMaxStamp = Smi::kMaxValue; |
27 if (stamp_->value() >= kMaxStamp) { | 40 if (stamp_->value() >= kMaxStamp) { |
28 stamp_ = Smi::kZero; | 41 stamp_ = Smi::kZero; |
29 } else { | 42 } else { |
30 stamp_ = Smi::FromInt(stamp_->value() + 1); | 43 stamp_ = Smi::FromInt(stamp_->value() + 1); |
31 } | 44 } |
32 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); | 45 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); |
33 for (int i = 0; i < kDSTSize; ++i) { | 46 for (int i = 0; i < kDSTSize; ++i) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 if (result == NULL || result->last_used > dst_[i].last_used) { | 379 if (result == NULL || result->last_used > dst_[i].last_used) { |
367 result = &dst_[i]; | 380 result = &dst_[i]; |
368 } | 381 } |
369 } | 382 } |
370 ClearSegment(result); | 383 ClearSegment(result); |
371 return result; | 384 return result; |
372 } | 385 } |
373 | 386 |
374 } // namespace internal | 387 } // namespace internal |
375 } // namespace v8 | 388 } // namespace v8 |
OLD | NEW |