Use range-based for loops in RulesRegistry code
[chromium-blink-merge.git] / base / i18n / timezone.cc
blobf668543ecdce2f1fc191d16f174ab2ac7d601bdd
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/i18n/timezone.h"
7 #include <string.h>
9 #include <map>
11 #include "base/memory/singleton.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "third_party/icu/source/i18n/unicode/timezone.h"
16 namespace base {
18 namespace {
20 class TimezoneMap {
21 public:
22 static TimezoneMap* GetInstance() {
23 return Singleton<TimezoneMap>::get();
26 std::string CountryCodeForTimezone(const std::string& olson_code) {
27 std::map<const char*, const char*, CompareCStrings>::iterator iter =
28 map_.find(olson_code.c_str());
29 if (iter != map_.end())
30 return iter->second;
32 return std::string();
35 private:
36 TimezoneMap() {
37 // These mappings are adapted from zone.tab, which is available at
38 // <http://www.ietf.org/timezones/data/zone.tab> and is a part of public
39 // domain.
40 struct OlsonCodeData {
41 const char* country_code;
42 const char* olson_code;
44 static const OlsonCodeData olson_code_data[] = {
45 { "AD", "Europe/Andorra" },
46 { "AE", "Asia/Dubai" },
47 { "AF", "Asia/Kabul" },
48 { "AG", "America/Antigua" },
49 { "AI", "America/Anguilla" },
50 { "AL", "Europe/Tirane" },
51 { "AM", "Asia/Yerevan" },
52 { "AO", "Africa/Luanda" },
53 { "AQ", "Antarctica/McMurdo" },
54 { "AQ", "Antarctica/Rothera" },
55 { "AQ", "Antarctica/Palmer" },
56 { "AQ", "Antarctica/Mawson" },
57 { "AQ", "Antarctica/Davis" },
58 { "AQ", "Antarctica/Casey" },
59 { "AQ", "Antarctica/Vostok" },
60 { "AQ", "Antarctica/DumontDUrville" },
61 { "AQ", "Antarctica/Syowa" },
62 { "AR", "America/Argentina/Buenos_Aires" },
63 { "AR", "America/Argentina/Cordoba" },
64 { "AR", "America/Argentina/Salta" },
65 { "AR", "America/Argentina/Jujuy" },
66 { "AR", "America/Argentina/Tucuman" },
67 { "AR", "America/Argentina/Catamarca" },
68 { "AR", "America/Argentina/La_Rioja" },
69 { "AR", "America/Argentina/San_Juan" },
70 { "AR", "America/Argentina/Mendoza" },
71 { "AR", "America/Argentina/San_Luis" },
72 { "AR", "America/Argentina/Rio_Gallegos" },
73 { "AR", "America/Argentina/Ushuaia" },
74 { "AS", "Pacific/Pago_Pago" },
75 { "AT", "Europe/Vienna" },
76 { "AU", "Australia/Lord_Howe" },
77 { "AU", "Antarctica/Macquarie" },
78 { "AU", "Australia/Hobart" },
79 { "AU", "Australia/Currie" },
80 { "AU", "Australia/Melbourne" },
81 { "AU", "Australia/Sydney" },
82 { "AU", "Australia/Broken_Hill" },
83 { "AU", "Australia/Brisbane" },
84 { "AU", "Australia/Lindeman" },
85 { "AU", "Australia/Adelaide" },
86 { "AU", "Australia/Darwin" },
87 { "AU", "Australia/Perth" },
88 { "AU", "Australia/Eucla" },
89 { "AW", "America/Aruba" },
90 { "AX", "Europe/Mariehamn" },
91 { "AZ", "Asia/Baku" },
92 { "BA", "Europe/Sarajevo" },
93 { "BB", "America/Barbados" },
94 { "BD", "Asia/Dhaka" },
95 { "BE", "Europe/Brussels" },
96 { "BF", "Africa/Ouagadougou" },
97 { "BG", "Europe/Sofia" },
98 { "BH", "Asia/Bahrain" },
99 { "BI", "Africa/Bujumbura" },
100 { "BJ", "Africa/Porto-Novo" },
101 { "BL", "America/St_Barthelemy" },
102 { "BM", "Atlantic/Bermuda" },
103 { "BN", "Asia/Brunei" },
104 { "BO", "America/La_Paz" },
105 { "BQ", "America/Kralendijk" },
106 { "BR", "America/Noronha" },
107 { "BR", "America/Belem" },
108 { "BR", "America/Fortaleza" },
109 { "BR", "America/Recife" },
110 { "BR", "America/Araguaina" },
111 { "BR", "America/Maceio" },
112 { "BR", "America/Bahia" },
113 { "BR", "America/Sao_Paulo" },
114 { "BR", "America/Campo_Grande" },
115 { "BR", "America/Cuiaba" },
116 { "BR", "America/Santarem" },
117 { "BR", "America/Porto_Velho" },
118 { "BR", "America/Boa_Vista" },
119 { "BR", "America/Manaus" },
120 { "BR", "America/Eirunepe" },
121 { "BR", "America/Rio_Branco" },
122 { "BS", "America/Nassau" },
123 { "BT", "Asia/Thimphu" },
124 { "BW", "Africa/Gaborone" },
125 { "BY", "Europe/Minsk" },
126 { "BZ", "America/Belize" },
127 { "CA", "America/St_Johns" },
128 { "CA", "America/Halifax" },
129 { "CA", "America/Glace_Bay" },
130 { "CA", "America/Moncton" },
131 { "CA", "America/Goose_Bay" },
132 { "CA", "America/Blanc-Sablon" },
133 { "CA", "America/Toronto" },
134 { "CA", "America/Nipigon" },
135 { "CA", "America/Thunder_Bay" },
136 { "CA", "America/Iqaluit" },
137 { "CA", "America/Pangnirtung" },
138 { "CA", "America/Resolute" },
139 { "CA", "America/Atikokan" },
140 { "CA", "America/Rankin_Inlet" },
141 { "CA", "America/Winnipeg" },
142 { "CA", "America/Rainy_River" },
143 { "CA", "America/Regina" },
144 { "CA", "America/Swift_Current" },
145 { "CA", "America/Edmonton" },
146 { "CA", "America/Cambridge_Bay" },
147 { "CA", "America/Yellowknife" },
148 { "CA", "America/Inuvik" },
149 { "CA", "America/Creston" },
150 { "CA", "America/Dawson_Creek" },
151 { "CA", "America/Vancouver" },
152 { "CA", "America/Whitehorse" },
153 { "CA", "America/Dawson" },
154 { "CC", "Indian/Cocos" },
155 { "CD", "Africa/Kinshasa" },
156 { "CD", "Africa/Lubumbashi" },
157 { "CF", "Africa/Bangui" },
158 { "CG", "Africa/Brazzaville" },
159 { "CH", "Europe/Zurich" },
160 { "CI", "Africa/Abidjan" },
161 { "CK", "Pacific/Rarotonga" },
162 { "CL", "America/Santiago" },
163 { "CL", "Pacific/Easter" },
164 { "CM", "Africa/Douala" },
165 { "CN", "Asia/Shanghai" },
166 { "CN", "Asia/Harbin" },
167 { "CN", "Asia/Chongqing" },
168 { "CN", "Asia/Urumqi" },
169 { "CN", "Asia/Kashgar" },
170 { "CO", "America/Bogota" },
171 { "CR", "America/Costa_Rica" },
172 { "CU", "America/Havana" },
173 { "CV", "Atlantic/Cape_Verde" },
174 { "CW", "America/Curacao" },
175 { "CX", "Indian/Christmas" },
176 { "CY", "Asia/Nicosia" },
177 { "CZ", "Europe/Prague" },
178 { "DE", "Europe/Berlin" },
179 { "DE", "Europe/Busingen" },
180 { "DJ", "Africa/Djibouti" },
181 { "DK", "Europe/Copenhagen" },
182 { "DM", "America/Dominica" },
183 { "DO", "America/Santo_Domingo" },
184 { "DZ", "Africa/Algiers" },
185 { "EC", "America/Guayaquil" },
186 { "EC", "Pacific/Galapagos" },
187 { "EE", "Europe/Tallinn" },
188 { "EG", "Africa/Cairo" },
189 { "EH", "Africa/El_Aaiun" },
190 { "ER", "Africa/Asmara" },
191 { "ES", "Europe/Madrid" },
192 { "ES", "Africa/Ceuta" },
193 { "ES", "Atlantic/Canary" },
194 { "ET", "Africa/Addis_Ababa" },
195 { "FI", "Europe/Helsinki" },
196 { "FJ", "Pacific/Fiji" },
197 { "FK", "Atlantic/Stanley" },
198 { "FM", "Pacific/Chuuk" },
199 { "FM", "Pacific/Pohnpei" },
200 { "FM", "Pacific/Kosrae" },
201 { "FO", "Atlantic/Faroe" },
202 { "FR", "Europe/Paris" },
203 { "GA", "Africa/Libreville" },
204 { "GB", "Europe/London" },
205 { "GD", "America/Grenada" },
206 { "GE", "Asia/Tbilisi" },
207 { "GF", "America/Cayenne" },
208 { "GG", "Europe/Guernsey" },
209 { "GH", "Africa/Accra" },
210 { "GI", "Europe/Gibraltar" },
211 { "GL", "America/Godthab" },
212 { "GL", "America/Danmarkshavn" },
213 { "GL", "America/Scoresbysund" },
214 { "GL", "America/Thule" },
215 { "GM", "Africa/Banjul" },
216 { "GN", "Africa/Conakry" },
217 { "GP", "America/Guadeloupe" },
218 { "GQ", "Africa/Malabo" },
219 { "GR", "Europe/Athens" },
220 { "GS", "Atlantic/South_Georgia" },
221 { "GT", "America/Guatemala" },
222 { "GU", "Pacific/Guam" },
223 { "GW", "Africa/Bissau" },
224 { "GY", "America/Guyana" },
225 { "HK", "Asia/Hong_Kong" },
226 { "HN", "America/Tegucigalpa" },
227 { "HR", "Europe/Zagreb" },
228 { "HT", "America/Port-au-Prince" },
229 { "HU", "Europe/Budapest" },
230 { "ID", "Asia/Jakarta" },
231 { "ID", "Asia/Pontianak" },
232 { "ID", "Asia/Makassar" },
233 { "ID", "Asia/Jayapura" },
234 { "IE", "Europe/Dublin" },
235 { "IL", "Asia/Jerusalem" },
236 { "IM", "Europe/Isle_of_Man" },
237 { "IN", "Asia/Kolkata" },
238 { "IO", "Indian/Chagos" },
239 { "IQ", "Asia/Baghdad" },
240 { "IR", "Asia/Tehran" },
241 { "IS", "Atlantic/Reykjavik" },
242 { "IT", "Europe/Rome" },
243 { "JE", "Europe/Jersey" },
244 { "JM", "America/Jamaica" },
245 { "JO", "Asia/Amman" },
246 { "JP", "Asia/Tokyo" },
247 { "KE", "Africa/Nairobi" },
248 { "KG", "Asia/Bishkek" },
249 { "KH", "Asia/Phnom_Penh" },
250 { "KI", "Pacific/Tarawa" },
251 { "KI", "Pacific/Enderbury" },
252 { "KI", "Pacific/Kiritimati" },
253 { "KM", "Indian/Comoro" },
254 { "KN", "America/St_Kitts" },
255 { "KP", "Asia/Pyongyang" },
256 { "KR", "Asia/Seoul" },
257 { "KW", "Asia/Kuwait" },
258 { "KY", "America/Cayman" },
259 { "KZ", "Asia/Almaty" },
260 { "KZ", "Asia/Qyzylorda" },
261 { "KZ", "Asia/Aqtobe" },
262 { "KZ", "Asia/Aqtau" },
263 { "KZ", "Asia/Oral" },
264 { "LA", "Asia/Vientiane" },
265 { "LB", "Asia/Beirut" },
266 { "LC", "America/St_Lucia" },
267 { "LI", "Europe/Vaduz" },
268 { "LK", "Asia/Colombo" },
269 { "LR", "Africa/Monrovia" },
270 { "LS", "Africa/Maseru" },
271 { "LT", "Europe/Vilnius" },
272 { "LU", "Europe/Luxembourg" },
273 { "LV", "Europe/Riga" },
274 { "LY", "Africa/Tripoli" },
275 { "MA", "Africa/Casablanca" },
276 { "MC", "Europe/Monaco" },
277 { "MD", "Europe/Chisinau" },
278 { "ME", "Europe/Podgorica" },
279 { "MF", "America/Marigot" },
280 { "MG", "Indian/Antananarivo" },
281 { "MH", "Pacific/Majuro" },
282 { "MH", "Pacific/Kwajalein" },
283 { "MK", "Europe/Skopje" },
284 { "ML", "Africa/Bamako" },
285 { "MM", "Asia/Rangoon" },
286 { "MN", "Asia/Ulaanbaatar" },
287 { "MN", "Asia/Hovd" },
288 { "MN", "Asia/Choibalsan" },
289 { "MO", "Asia/Macau" },
290 { "MP", "Pacific/Saipan" },
291 { "MQ", "America/Martinique" },
292 { "MR", "Africa/Nouakchott" },
293 { "MS", "America/Montserrat" },
294 { "MT", "Europe/Malta" },
295 { "MU", "Indian/Mauritius" },
296 { "MV", "Indian/Maldives" },
297 { "MW", "Africa/Blantyre" },
298 { "MX", "America/Mexico_City" },
299 { "MX", "America/Cancun" },
300 { "MX", "America/Merida" },
301 { "MX", "America/Monterrey" },
302 { "MX", "America/Matamoros" },
303 { "MX", "America/Mazatlan" },
304 { "MX", "America/Chihuahua" },
305 { "MX", "America/Ojinaga" },
306 { "MX", "America/Hermosillo" },
307 { "MX", "America/Tijuana" },
308 { "MX", "America/Santa_Isabel" },
309 { "MX", "America/Bahia_Banderas" },
310 { "MY", "Asia/Kuala_Lumpur" },
311 { "MY", "Asia/Kuching" },
312 { "MZ", "Africa/Maputo" },
313 { "NA", "Africa/Windhoek" },
314 { "NC", "Pacific/Noumea" },
315 { "NE", "Africa/Niamey" },
316 { "NF", "Pacific/Norfolk" },
317 { "NG", "Africa/Lagos" },
318 { "NI", "America/Managua" },
319 { "NL", "Europe/Amsterdam" },
320 { "NO", "Europe/Oslo" },
321 { "NP", "Asia/Kathmandu" },
322 { "NR", "Pacific/Nauru" },
323 { "NU", "Pacific/Niue" },
324 { "NZ", "Pacific/Auckland" },
325 { "NZ", "Pacific/Chatham" },
326 { "OM", "Asia/Muscat" },
327 { "PA", "America/Panama" },
328 { "PE", "America/Lima" },
329 { "PF", "Pacific/Tahiti" },
330 { "PF", "Pacific/Marquesas" },
331 { "PF", "Pacific/Gambier" },
332 { "PG", "Pacific/Port_Moresby" },
333 { "PH", "Asia/Manila" },
334 { "PK", "Asia/Karachi" },
335 { "PL", "Europe/Warsaw" },
336 { "PM", "America/Miquelon" },
337 { "PN", "Pacific/Pitcairn" },
338 { "PR", "America/Puerto_Rico" },
339 { "PS", "Asia/Gaza" },
340 { "PS", "Asia/Hebron" },
341 { "PT", "Europe/Lisbon" },
342 { "PT", "Atlantic/Madeira" },
343 { "PT", "Atlantic/Azores" },
344 { "PW", "Pacific/Palau" },
345 { "PY", "America/Asuncion" },
346 { "QA", "Asia/Qatar" },
347 { "RE", "Indian/Reunion" },
348 { "RO", "Europe/Bucharest" },
349 { "RS", "Europe/Belgrade" },
350 { "RU", "Europe/Kaliningrad" },
351 { "RU", "Europe/Moscow" },
352 { "RU", "Europe/Volgograd" },
353 { "RU", "Europe/Samara" },
354 { "RU", "Asia/Yekaterinburg" },
355 { "RU", "Asia/Omsk" },
356 { "RU", "Asia/Novosibirsk" },
357 { "RU", "Asia/Novokuznetsk" },
358 { "RU", "Asia/Krasnoyarsk" },
359 { "RU", "Asia/Irkutsk" },
360 { "RU", "Asia/Yakutsk" },
361 { "RU", "Asia/Khandyga" },
362 { "RU", "Asia/Vladivostok" },
363 { "RU", "Asia/Sakhalin" },
364 { "RU", "Asia/Ust-Nera" },
365 { "RU", "Asia/Magadan" },
366 { "RU", "Asia/Kamchatka" },
367 { "RU", "Asia/Anadyr" },
368 { "RW", "Africa/Kigali" },
369 { "SA", "Asia/Riyadh" },
370 { "SB", "Pacific/Guadalcanal" },
371 { "SC", "Indian/Mahe" },
372 { "SD", "Africa/Khartoum" },
373 { "SE", "Europe/Stockholm" },
374 { "SG", "Asia/Singapore" },
375 { "SH", "Atlantic/St_Helena" },
376 { "SI", "Europe/Ljubljana" },
377 { "SJ", "Arctic/Longyearbyen" },
378 { "SK", "Europe/Bratislava" },
379 { "SL", "Africa/Freetown" },
380 { "SM", "Europe/San_Marino" },
381 { "SN", "Africa/Dakar" },
382 { "SO", "Africa/Mogadishu" },
383 { "SR", "America/Paramaribo" },
384 { "SS", "Africa/Juba" },
385 { "ST", "Africa/Sao_Tome" },
386 { "SV", "America/El_Salvador" },
387 { "SX", "America/Lower_Princes" },
388 { "SY", "Asia/Damascus" },
389 { "SZ", "Africa/Mbabane" },
390 { "TC", "America/Grand_Turk" },
391 { "TD", "Africa/Ndjamena" },
392 { "TF", "Indian/Kerguelen" },
393 { "TG", "Africa/Lome" },
394 { "TH", "Asia/Bangkok" },
395 { "TJ", "Asia/Dushanbe" },
396 { "TK", "Pacific/Fakaofo" },
397 { "TL", "Asia/Dili" },
398 { "TM", "Asia/Ashgabat" },
399 { "TN", "Africa/Tunis" },
400 { "TO", "Pacific/Tongatapu" },
401 { "TR", "Europe/Istanbul" },
402 { "TT", "America/Port_of_Spain" },
403 { "TV", "Pacific/Funafuti" },
404 { "TW", "Asia/Taipei" },
405 { "TZ", "Africa/Dar_es_Salaam" },
406 { "UA", "Europe/Kiev" },
407 { "UA", "Europe/Uzhgorod" },
408 { "UA", "Europe/Zaporozhye" },
409 { "UA", "Europe/Simferopol" },
410 { "UG", "Africa/Kampala" },
411 { "UM", "Pacific/Johnston" },
412 { "UM", "Pacific/Midway" },
413 { "UM", "Pacific/Wake" },
414 { "US", "America/New_York" },
415 { "US", "America/Detroit" },
416 { "US", "America/Kentucky/Louisville" },
417 { "US", "America/Kentucky/Monticello" },
418 { "US", "America/Indiana/Indianapolis" },
419 { "US", "America/Indiana/Vincennes" },
420 { "US", "America/Indiana/Winamac" },
421 { "US", "America/Indiana/Marengo" },
422 { "US", "America/Indiana/Petersburg" },
423 { "US", "America/Indiana/Vevay" },
424 { "US", "America/Chicago" },
425 { "US", "America/Indiana/Tell_City" },
426 { "US", "America/Indiana/Knox" },
427 { "US", "America/Menominee" },
428 { "US", "America/North_Dakota/Center" },
429 { "US", "America/North_Dakota/New_Salem" },
430 { "US", "America/North_Dakota/Beulah" },
431 { "US", "America/Denver" },
432 { "US", "America/Boise" },
433 { "US", "America/Phoenix" },
434 { "US", "America/Los_Angeles" },
435 { "US", "America/Anchorage" },
436 { "US", "America/Juneau" },
437 { "US", "America/Sitka" },
438 { "US", "America/Yakutat" },
439 { "US", "America/Nome" },
440 { "US", "America/Adak" },
441 { "US", "America/Metlakatla" },
442 { "US", "Pacific/Honolulu" },
443 { "UY", "America/Montevideo" },
444 { "UZ", "Asia/Samarkand" },
445 { "UZ", "Asia/Tashkent" },
446 { "VA", "Europe/Vatican" },
447 { "VC", "America/St_Vincent" },
448 { "VE", "America/Caracas" },
449 { "VG", "America/Tortola" },
450 { "VI", "America/St_Thomas" },
451 { "VN", "Asia/Ho_Chi_Minh" },
452 { "VU", "Pacific/Efate" },
453 { "WF", "Pacific/Wallis" },
454 { "WS", "Pacific/Apia" },
455 { "YE", "Asia/Aden" },
456 { "YT", "Indian/Mayotte" },
457 { "ZA", "Africa/Johannesburg" },
458 { "ZM", "Africa/Lusaka" },
459 { "ZW", "Africa/Harare" },
460 // The mappings below are custom additions to zone.tab.
461 { "GB", "Etc/GMT" },
462 { "GB", "Etc/UTC" },
463 { "GB", "Etc/UCT" },
466 for (size_t i = 0; i < arraysize(olson_code_data); ++i)
467 map_[olson_code_data[i].olson_code] = olson_code_data[i].country_code;
469 // These are mapping from old codenames to new codenames. They are also
470 // part of public domain, and available at
471 // <http://www.ietf.org/timezones/data/backward>.
472 struct LinkData {
473 const char* old_code;
474 const char* new_code;
476 static const LinkData link_data[] = {
477 { "Africa/Asmera", "Africa/Asmara" },
478 { "Africa/Timbuktu", "Africa/Bamako" },
479 { "America/Argentina/ComodRivadavia", "America/Argentina/Catamarca" },
480 { "America/Atka", "America/Adak" },
481 { "America/Buenos_Aires", "America/Argentina/Buenos_Aires" },
482 { "America/Catamarca", "America/Argentina/Catamarca" },
483 { "America/Coral_Harbour", "America/Atikokan" },
484 { "America/Cordoba", "America/Argentina/Cordoba" },
485 { "America/Ensenada", "America/Tijuana" },
486 { "America/Fort_Wayne", "America/Indiana/Indianapolis" },
487 { "America/Indianapolis", "America/Indiana/Indianapolis" },
488 { "America/Jujuy", "America/Argentina/Jujuy" },
489 { "America/Knox_IN", "America/Indiana/Knox" },
490 { "America/Louisville", "America/Kentucky/Louisville" },
491 { "America/Mendoza", "America/Argentina/Mendoza" },
492 { "America/Porto_Acre", "America/Rio_Branco" },
493 { "America/Rosario", "America/Argentina/Cordoba" },
494 { "America/Virgin", "America/St_Thomas" },
495 { "Asia/Ashkhabad", "Asia/Ashgabat" },
496 { "Asia/Chungking", "Asia/Chongqing" },
497 { "Asia/Dacca", "Asia/Dhaka" },
498 { "Asia/Katmandu", "Asia/Kathmandu" },
499 { "Asia/Calcutta", "Asia/Kolkata" },
500 { "Asia/Macao", "Asia/Macau" },
501 { "Asia/Tel_Aviv", "Asia/Jerusalem" },
502 { "Asia/Saigon", "Asia/Ho_Chi_Minh" },
503 { "Asia/Thimbu", "Asia/Thimphu" },
504 { "Asia/Ujung_Pandang", "Asia/Makassar" },
505 { "Asia/Ulan_Bator", "Asia/Ulaanbaatar" },
506 { "Atlantic/Faeroe", "Atlantic/Faroe" },
507 { "Atlantic/Jan_Mayen", "Europe/Oslo" },
508 { "Australia/ACT", "Australia/Sydney" },
509 { "Australia/Canberra", "Australia/Sydney" },
510 { "Australia/LHI", "Australia/Lord_Howe" },
511 { "Australia/NSW", "Australia/Sydney" },
512 { "Australia/North", "Australia/Darwin" },
513 { "Australia/Queensland", "Australia/Brisbane" },
514 { "Australia/South", "Australia/Adelaide" },
515 { "Australia/Tasmania", "Australia/Hobart" },
516 { "Australia/Victoria", "Australia/Melbourne" },
517 { "Australia/West", "Australia/Perth" },
518 { "Australia/Yancowinna", "Australia/Broken_Hill" },
519 { "Brazil/Acre", "America/Rio_Branco" },
520 { "Brazil/DeNoronha", "America/Noronha" },
521 { "Brazil/East", "America/Sao_Paulo" },
522 { "Brazil/West", "America/Manaus" },
523 { "Canada/Atlantic", "America/Halifax" },
524 { "Canada/Central", "America/Winnipeg" },
525 { "Canada/East-Saskatchewan", "America/Regina" },
526 { "Canada/Eastern", "America/Toronto" },
527 { "Canada/Mountain", "America/Edmonton" },
528 { "Canada/Newfoundland", "America/St_Johns" },
529 { "Canada/Pacific", "America/Vancouver" },
530 { "Canada/Saskatchewan", "America/Regina" },
531 { "Canada/Yukon", "America/Whitehorse" },
532 { "Chile/Continental", "America/Santiago" },
533 { "Chile/EasterIsland", "Pacific/Easter" },
534 { "Cuba", "America/Havana" },
535 { "Egypt", "Africa/Cairo" },
536 { "Eire", "Europe/Dublin" },
537 { "Europe/Belfast", "Europe/London" },
538 { "Europe/Tiraspol", "Europe/Chisinau" },
539 { "GB", "Europe/London" },
540 { "GB-Eire", "Europe/London" },
541 { "GMT+0", "Etc/GMT" },
542 { "GMT-0", "Etc/GMT" },
543 { "GMT0", "Etc/GMT" },
544 { "Greenwich", "Etc/GMT" },
545 { "Hongkong", "Asia/Hong_Kong" },
546 { "Iceland", "Atlantic/Reykjavik" },
547 { "Iran", "Asia/Tehran" },
548 { "Israel", "Asia/Jerusalem" },
549 { "Jamaica", "America/Jamaica" },
550 { "Japan", "Asia/Tokyo" },
551 { "Kwajalein", "Pacific/Kwajalein" },
552 { "Libya", "Africa/Tripoli" },
553 { "Mexico/BajaNorte", "America/Tijuana" },
554 { "Mexico/BajaSur", "America/Mazatlan" },
555 { "Mexico/General", "America/Mexico_City" },
556 { "NZ", "Pacific/Auckland" },
557 { "NZ-CHAT", "Pacific/Chatham" },
558 { "Navajo", "America/Denver" },
559 { "PRC", "Asia/Shanghai" },
560 { "Pacific/Samoa", "Pacific/Pago_Pago" },
561 { "Pacific/Yap", "Pacific/Chuuk" },
562 { "Pacific/Truk", "Pacific/Chuuk" },
563 { "Pacific/Ponape", "Pacific/Pohnpei" },
564 { "Poland", "Europe/Warsaw" },
565 { "Portugal", "Europe/Lisbon" },
566 { "ROC", "Asia/Taipei" },
567 { "ROK", "Asia/Seoul" },
568 { "Singapore", "Asia/Singapore" },
569 { "Turkey", "Europe/Istanbul" },
570 { "UCT", "Etc/UCT" },
571 { "US/Alaska", "America/Anchorage" },
572 { "US/Aleutian", "America/Adak" },
573 { "US/Arizona", "America/Phoenix" },
574 { "US/Central", "America/Chicago" },
575 { "US/East-Indiana", "America/Indiana/Indianapolis" },
576 { "US/Eastern", "America/New_York" },
577 { "US/Hawaii", "Pacific/Honolulu" },
578 { "US/Indiana-Starke", "America/Indiana/Knox" },
579 { "US/Michigan", "America/Detroit" },
580 { "US/Mountain", "America/Denver" },
581 { "US/Pacific", "America/Los_Angeles" },
582 { "US/Samoa", "Pacific/Pago_Pago" },
583 { "UTC", "Etc/UTC" },
584 { "Universal", "Etc/UTC" },
585 { "W-SU", "Europe/Moscow" },
586 { "Zulu", "Etc/UTC" },
589 for (size_t i = 0; i < arraysize(link_data); ++i)
590 map_[link_data[i].old_code] = map_[link_data[i].new_code];
593 friend struct DefaultSingletonTraits<TimezoneMap>;
595 struct CompareCStrings {
596 bool operator()(const char* str1, const char* str2) const {
597 return strcmp(str1, str2) < 0;
600 std::map<const char*, const char*, CompareCStrings> map_;
602 DISALLOW_COPY_AND_ASSIGN(TimezoneMap);
605 } // namespace
607 std::string CountryCodeForCurrentTimezone() {
608 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
609 icu::UnicodeString id;
610 zone->getID(id);
611 string16 olson_code(id.getBuffer(), id.length());
612 return TimezoneMap::GetInstance()->CountryCodeForTimezone(
613 UTF16ToUTF8(olson_code));
616 } // namespace base