| 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 ICUTimezoneCache() |
| 33 : base::OS::CreateTimezoneCache() |
| 34 #else |
| 35 base::OS::CreateTimezoneCache() |
| 36 #endif |
| 37 ) { |
| 38 ResetDateCache(); |
| 39 } |
| 24 | 40 |
| 25 void DateCache::ResetDateCache() { | 41 void DateCache::ResetDateCache() { |
| 26 static const int kMaxStamp = Smi::kMaxValue; | 42 static const int kMaxStamp = Smi::kMaxValue; |
| 27 if (stamp_->value() >= kMaxStamp) { | 43 if (stamp_->value() >= kMaxStamp) { |
| 28 stamp_ = Smi::kZero; | 44 stamp_ = Smi::kZero; |
| 29 } else { | 45 } else { |
| 30 stamp_ = Smi::FromInt(stamp_->value() + 1); | 46 stamp_ = Smi::FromInt(stamp_->value() + 1); |
| 31 } | 47 } |
| 32 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); | 48 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); |
| 33 for (int i = 0; i < kDSTSize; ++i) { | 49 for (int i = 0; i < kDSTSize; ++i) { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (result == NULL || result->last_used > dst_[i].last_used) { | 384 if (result == NULL || result->last_used > dst_[i].last_used) { |
| 369 result = &dst_[i]; | 385 result = &dst_[i]; |
| 370 } | 386 } |
| 371 } | 387 } |
| 372 ClearSegment(result); | 388 ClearSegment(result); |
| 373 return result; | 389 return result; |
| 374 } | 390 } |
| 375 | 391 |
| 376 } // namespace internal | 392 } // namespace internal |
| 377 } // namespace v8 | 393 } // namespace v8 |
| OLD | NEW |