OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 // limitations under the License. | 4 // limitations under the License. |
5 | 5 |
6 #ifndef V8_I18N_H_ | 6 #ifndef V8_I18N_H_ |
7 #define V8_I18N_H_ | 7 #define V8_I18N_H_ |
8 | 8 |
9 #include "src/base/timezone-cache.h" | |
9 #include "src/objects.h" | 10 #include "src/objects.h" |
10 #include "unicode/uversion.h" | 11 #include "unicode/uversion.h" |
11 | 12 |
12 namespace U_ICU_NAMESPACE { | 13 namespace U_ICU_NAMESPACE { |
13 class BreakIterator; | 14 class BreakIterator; |
14 class Collator; | 15 class Collator; |
15 class DecimalFormat; | 16 class DecimalFormat; |
16 class SimpleDateFormat; | 17 class SimpleDateFormat; |
18 class TimeZone; | |
17 } | 19 } |
18 | 20 |
19 namespace v8 { | 21 namespace v8 { |
20 namespace internal { | 22 namespace internal { |
21 | 23 |
22 template <typename T> | 24 template <typename T> |
23 class Handle; | 25 class Handle; |
24 | 26 |
25 class DateFormat { | 27 class DateFormat { |
26 public: | 28 public: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 | 123 |
122 // Layout description. | 124 // Layout description. |
123 static const int kBreakIterator = JSObject::kHeaderSize; | 125 static const int kBreakIterator = JSObject::kHeaderSize; |
124 static const int kUnicodeString = kBreakIterator + kPointerSize; | 126 static const int kUnicodeString = kBreakIterator + kPointerSize; |
125 static const int kSize = kUnicodeString + kPointerSize; | 127 static const int kSize = kUnicodeString + kPointerSize; |
126 | 128 |
127 private: | 129 private: |
128 V8BreakIterator(); | 130 V8BreakIterator(); |
129 }; | 131 }; |
130 | 132 |
133 // ICUTimezoneCache calls out to ICU for TimezoneCache | |
134 // functionality in a straightforward way. | |
135 class ICUTimezoneCache : public base::TimezoneCache { | |
136 public: | |
137 ICUTimezoneCache(); | |
138 | |
139 ~ICUTimezoneCache() override; | |
140 | |
141 const char* LocalTimezone(double time_ms) override; | |
142 | |
143 double DaylightSavingsOffset(double time_ms) override; | |
144 | |
145 double LocalTimeOffset() override; | |
146 | |
147 void Clear() override; | |
148 | |
149 private: | |
150 icu::TimeZone* GetTimeZone(); | |
151 | |
152 bool GetOffsets(double time_ms, int32_t* raw_offset, int32_t* dst_offset); | |
153 | |
154 icu::TimeZone* timezone_; | |
155 | |
156 static const int32_t kMaxTimezoneChars = 20; | |
ulan
2017/03/03 13:20:27
Can we use std::string here?
Dan Ehrenberg
2017/03/03 15:06:54
Do you mean that we'd make LocalTimezone() return
ulan
2017/03/10 17:55:38
Ah, sorry, nevermind. I meant the second, but I se
| |
157 char timezone_name_[kMaxTimezoneChars]; | |
158 char dst_timezone_name_[kMaxTimezoneChars]; | |
159 }; | |
160 | |
161 // ICUOSTimezoneCache defers to the OS TimezoneCache | |
162 // for LocalTimezone if ICU provides a timezone name | |
163 // which starts with GMT. Otherwise, it uses ICU for | |
164 // all operaitons. The issue here is that CLDR declines | |
165 // to specify short names for many time zones, when the | |
166 // OS often does know an appropriate short name. | |
167 class ICUOSTimezoneCache : public ICUTimezoneCache { | |
168 public: | |
169 ICUOSTimezoneCache(); | |
170 | |
171 ~ICUOSTimezoneCache() override; | |
172 | |
173 const char* LocalTimezone(double time_ms) override; | |
174 | |
175 void Clear() override; | |
176 | |
177 private: | |
178 TimezoneCache* os_tz_cache_; | |
179 }; | |
180 | |
131 } // namespace internal | 181 } // namespace internal |
132 } // namespace v8 | 182 } // namespace v8 |
133 | 183 |
134 #endif // V8_I18N_H_ | 184 #endif // V8_I18N_H_ |
OLD | NEW |