OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 }; | 100 }; |
101 | 101 |
102 static int64_t TimeFromYearMonthDay(DateCache* date_cache, | 102 static int64_t TimeFromYearMonthDay(DateCache* date_cache, |
103 int year, | 103 int year, |
104 int month, | 104 int month, |
105 int day) { | 105 int day) { |
106 int64_t result = date_cache->DaysFromYearMonth(year, month); | 106 int64_t result = date_cache->DaysFromYearMonth(year, month); |
107 return (result + day - 1) * DateCache::kMsPerDay; | 107 return (result + day - 1) * DateCache::kMsPerDay; |
108 } | 108 } |
109 | 109 |
| 110 |
110 static void CheckDST(int64_t time) { | 111 static void CheckDST(int64_t time) { |
111 Isolate* isolate = Isolate::Current(); | 112 Isolate* isolate = Isolate::Current(); |
112 DateCache* date_cache = isolate->date_cache(); | 113 DateCache* date_cache = isolate->date_cache(); |
113 int64_t actual = date_cache->ToLocal(time); | 114 int64_t actual = date_cache->ToLocal(time); |
114 int64_t expected = time + date_cache->GetLocalOffsetFromOS() + | 115 int64_t expected = time + date_cache->GetLocalOffsetFromOS() + |
115 date_cache->GetDaylightSavingsOffsetFromOS(time / 1000); | 116 date_cache->GetDaylightSavingsOffsetFromOS(time / 1000); |
116 CHECK_EQ(actual, expected); | 117 CHECK_EQ(actual, expected); |
117 } | 118 } |
118 | 119 |
119 | 120 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 CheckDST(TimeFromYearMonthDay(date_cache, year, 5, 5)); | 160 CheckDST(TimeFromYearMonthDay(date_cache, year, 5, 5)); |
160 } | 161 } |
161 CheckDST((august_20 + september_10) / 2); | 162 CheckDST((august_20 + september_10) / 2); |
162 CheckDST(september_10); | 163 CheckDST(september_10); |
163 CheckDST(september_10 + 2 * 3600); | 164 CheckDST(september_10 + 2 * 3600); |
164 CheckDST(september_10 + 2 * 3600 - 1000); | 165 CheckDST(september_10 + 2 * 3600 - 1000); |
165 CheckDST(august_20 + 2 * 3600); | 166 CheckDST(august_20 + 2 * 3600); |
166 CheckDST(august_20 + 2 * 3600 - 1000); | 167 CheckDST(august_20 + 2 * 3600 - 1000); |
167 CheckDST(august_20); | 168 CheckDST(august_20); |
168 } | 169 } |
OLD | NEW |