| 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 | |
| 14 namespace v8 { | 10 namespace v8 { |
| 15 namespace internal { | 11 namespace internal { |
| 16 | 12 |
| 17 | 13 |
| 18 static const int kDaysIn4Years = 4 * 365 + 1; | 14 static const int kDaysIn4Years = 4 * 365 + 1; |
| 19 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; | 15 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; |
| 20 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; | 16 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; |
| 21 static const int kDays1970to2000 = 30 * 365 + 7; | 17 static const int kDays1970to2000 = 30 * 365 + 7; |
| 22 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - | 18 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - |
| 23 kDays1970to2000; | 19 kDays1970to2000; |
| 24 static const int kYearsOffset = 400000; | 20 static const int kYearsOffset = 400000; |
| 25 static const char kDaysInMonths[] = | 21 static const char kDaysInMonths[] = |
| 26 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 22 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
| 27 | 23 |
| 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 } | |
| 40 | 24 |
| 41 void DateCache::ResetDateCache() { | 25 void DateCache::ResetDateCache() { |
| 42 static const int kMaxStamp = Smi::kMaxValue; | 26 static const int kMaxStamp = Smi::kMaxValue; |
| 43 if (stamp_->value() >= kMaxStamp) { | 27 if (stamp_->value() >= kMaxStamp) { |
| 44 stamp_ = Smi::kZero; | 28 stamp_ = Smi::kZero; |
| 45 } else { | 29 } else { |
| 46 stamp_ = Smi::FromInt(stamp_->value() + 1); | 30 stamp_ = Smi::FromInt(stamp_->value() + 1); |
| 47 } | 31 } |
| 48 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); | 32 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); |
| 49 for (int i = 0; i < kDSTSize; ++i) { | 33 for (int i = 0; i < kDSTSize; ++i) { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 if (result == NULL || result->last_used > dst_[i].last_used) { | 368 if (result == NULL || result->last_used > dst_[i].last_used) { |
| 385 result = &dst_[i]; | 369 result = &dst_[i]; |
| 386 } | 370 } |
| 387 } | 371 } |
| 388 ClearSegment(result); | 372 ClearSegment(result); |
| 389 return result; | 373 return result; |
| 390 } | 374 } |
| 391 | 375 |
| 392 } // namespace internal | 376 } // namespace internal |
| 393 } // namespace v8 | 377 } // namespace v8 |
| OLD | NEW |