34 using namespace v8::internal;
39 int year, start_month, start_day, end_month, end_day, offset_sec;
43 : local_offset_(local_offset), rules_(rules), rules_count_(rules_count) {}
47 int days = DaysFromTime(time_sec * 1000);
48 int time_in_day_sec = TimeInDay(time_sec * 1000, days) / 1000;
50 YearMonthDayFromDays(days, &year, &month, &day);
51 Rule* rule = FindRuleFor(year, month, day, time_in_day_sec);
61 Rule* FindRuleFor(
int year,
int month,
int day,
int time_in_day_sec) {
63 for (
int i = 0; i < rules_count_; i++)
64 if (Match(&rules_[i], year, month, day, time_in_day_sec)) {
71 bool Match(Rule* rule,
int year,
int month,
int day,
int time_in_day_sec) {
72 if (rule->year != 0 && rule->year != year)
return false;
73 if (rule->start_month > month)
return false;
74 if (rule->end_month < month)
return false;
75 int start_day = ComputeRuleDay(year, rule->start_month, rule->start_day);
76 if (rule->start_month == month && start_day > day)
return false;
77 if (rule->start_month == month && start_day == day &&
78 2 * 3600 > time_in_day_sec)
80 int end_day = ComputeRuleDay(year, rule->end_month, rule->end_day);
81 if (rule->end_month == month && end_day < day)
return false;
82 if (rule->end_month == month && end_day == day &&
83 2 * 3600 <= time_in_day_sec)
89 int ComputeRuleDay(
int year,
int month,
int day) {
90 if (day != 0)
return day;
91 int days = DaysFromYearMonth(year, month);
93 while (Weekday(days + day) != 6) day++;
102 static int64_t TimeFromYearMonthDay(
DateCache* date_cache,
110 static void CheckDST(int64_t time) {
111 Isolate* isolate = Isolate::Current();
113 int64_t actual = date_cache->
ToLocal(time);
123 Isolate* isolate = Isolate::Current();
125 {0, 2, 0, 10, 0, 3600},
126 {2010, 2, 0, 7, 20, 3600},
127 {2010, 7, 20, 8, 10, 0},
128 {2010, 8, 10, 10, 0, 3600},
131 int local_offset_ms = -36000000;
138 int64_t start_of_2010 = TimeFromYearMonthDay(date_cache, 2010, 0, 1);
139 int64_t start_of_2011 = TimeFromYearMonthDay(date_cache, 2011, 0, 1);
140 int64_t august_20 = TimeFromYearMonthDay(date_cache, 2010, 7, 20);
141 int64_t september_10 = TimeFromYearMonthDay(date_cache, 2010, 8, 10);
142 CheckDST((august_20 + september_10) / 2);
143 CheckDST(september_10);
144 CheckDST(september_10 + 2 * 3600);
145 CheckDST(september_10 + 2 * 3600 - 1000);
146 CheckDST(august_20 + 2 * 3600);
147 CheckDST(august_20 + 2 * 3600 - 1000);
150 for (int64_t time = start_of_2011 + 2 * 3600;
151 time >= start_of_2010;
154 CheckDST(time - 1000);
155 CheckDST(time + 1000);
158 for (
int year = 2100; year >= 2010; year--) {
159 CheckDST(TimeFromYearMonthDay(date_cache, year, 5, 5));
161 CheckDST((august_20 + september_10) / 2);
162 CheckDST(september_10);
163 CheckDST(september_10 + 2 * 3600);
164 CheckDST(september_10 + 2 * 3600 - 1000);
165 CheckDST(august_20 + 2 * 3600);
166 CheckDST(august_20 + 2 * 3600 - 1000);
void set_date_cache(DateCache *date_cache)
#define CHECK_EQ(expected, value)
DateCacheMock(int local_offset, Rule *rules, int rules_count)
virtual int GetLocalOffsetFromOS()
virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec)
virtual int GetLocalOffsetFromOS()
virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec)
int DaysFromYearMonth(int year, int month)
static const int64_t kMsPerDay
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
int64_t ToLocal(int64_t time_ms)