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 namespace v8 { | 10 namespace v8 { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 year1 / 400 - | 168 year1 / 400 - |
169 base_day; | 169 base_day; |
170 | 170 |
171 if ((year % 4 != 0) || (year % 100 == 0 && year % 400 != 0)) { | 171 if ((year % 4 != 0) || (year % 100 == 0 && year % 400 != 0)) { |
172 return day_from_year + day_from_month[month]; | 172 return day_from_year + day_from_month[month]; |
173 } | 173 } |
174 return day_from_year + day_from_month_leap[month]; | 174 return day_from_year + day_from_month_leap[month]; |
175 } | 175 } |
176 | 176 |
177 | 177 |
| 178 void DateCache::BreakDown(int64_t time_ms, int* year, int* month, int* day, |
| 179 int* weekday, int* hour, int* min, int* sec, |
| 180 int* ms) { |
| 181 int const days = DaysFromTime(time_ms); |
| 182 int const time_in_day_ms = TimeInDay(time_ms, days); |
| 183 YearMonthDayFromDays(days, year, month, day); |
| 184 *weekday = Weekday(days); |
| 185 *hour = time_in_day_ms / (60 * 60 * 1000); |
| 186 *min = (time_in_day_ms / (60 * 1000)) % 60; |
| 187 *sec = (time_in_day_ms / 1000) % 60; |
| 188 *ms = time_in_day_ms % 1000; |
| 189 } |
| 190 |
| 191 |
178 void DateCache::ExtendTheAfterSegment(int time_sec, int offset_ms) { | 192 void DateCache::ExtendTheAfterSegment(int time_sec, int offset_ms) { |
179 if (after_->offset_ms == offset_ms && | 193 if (after_->offset_ms == offset_ms && |
180 after_->start_sec <= time_sec + kDefaultDSTDeltaInSec && | 194 after_->start_sec <= time_sec + kDefaultDSTDeltaInSec && |
181 time_sec <= after_->end_sec) { | 195 time_sec <= after_->end_sec) { |
182 // Extend the after_ segment. | 196 // Extend the after_ segment. |
183 after_->start_sec = time_sec; | 197 after_->start_sec = time_sec; |
184 } else { | 198 } else { |
185 // The after_ segment is either invalid or starts too late. | 199 // The after_ segment is either invalid or starts too late. |
186 if (after_->start_sec <= after_->end_sec) { | 200 if (after_->start_sec <= after_->end_sec) { |
187 // If the after_ segment is valid, replace it with a new segment. | 201 // If the after_ segment is valid, replace it with a new segment. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (result == NULL || result->last_used > dst_[i].last_used) { | 366 if (result == NULL || result->last_used > dst_[i].last_used) { |
353 result = &dst_[i]; | 367 result = &dst_[i]; |
354 } | 368 } |
355 } | 369 } |
356 ClearSegment(result); | 370 ClearSegment(result); |
357 return result; | 371 return result; |
358 } | 372 } |
359 | 373 |
360 } // namespace internal | 374 } // namespace internal |
361 } // namespace v8 | 375 } // namespace v8 |
OLD | NEW |