timezone 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/License.txt +19 -0
- data/README.markdown +43 -0
- data/Rakefile +2 -0
- data/data/Africa/Abidjan.json +21 -0
- data/data/Africa/Accra.json +147 -0
- data/data/Africa/Addis_Ababa.json +30 -0
- data/data/Africa/Algiers.json +318 -0
- data/data/Africa/Asmara.json +39 -0
- data/data/Africa/Bamako.json +39 -0
- data/data/Africa/Bangui.json +21 -0
- data/data/Africa/Banjul.json +39 -0
- data/data/Africa/Bissau.json +30 -0
- data/data/Africa/Blantyre.json +21 -0
- data/data/Africa/Brazzaville.json +21 -0
- data/data/Africa/Bujumbura.json +21 -0
- data/data/Africa/Cairo.json +1839 -0
- data/data/Africa/Casablanca.json +237 -0
- data/data/Africa/Ceuta.json +1380 -0
- data/data/Africa/Conakry.json +39 -0
- data/data/Africa/Dakar.json +30 -0
- data/data/Africa/Dar_es_Salaam.json +39 -0
- data/data/Africa/Djibouti.json +21 -0
- data/data/Africa/Douala.json +21 -0
- data/data/Africa/El_Aaiun.json +30 -0
- data/data/Africa/Freetown.json +291 -0
- data/data/Africa/Gaborone.json +39 -0
- data/data/Africa/Harare.json +21 -0
- data/data/Africa/Johannesburg.json +66 -0
- data/data/Africa/Kampala.json +48 -0
- data/data/Africa/Khartoum.json +318 -0
- data/data/Africa/Kigali.json +21 -0
- data/data/Africa/Kinshasa.json +21 -0
- data/data/Africa/Lagos.json +21 -0
- data/data/Africa/Libreville.json +21 -0
- data/data/Africa/Lome.json +21 -0
- data/data/Africa/Luanda.json +30 -0
- data/data/Africa/Lubumbashi.json +21 -0
- data/data/Africa/Lusaka.json +21 -0
- data/data/Africa/Malabo.json +30 -0
- data/data/Africa/Maputo.json +21 -0
- data/data/Africa/Maseru.json +39 -0
- data/data/Africa/Mbabane.json +21 -0
- data/data/Africa/Mogadishu.json +39 -0
- data/data/Africa/Monrovia.json +39 -0
- data/data/Africa/Nairobi.json +48 -0
- data/data/Africa/Ndjamena.json +39 -0
- data/data/Africa/Niamey.json +39 -0
- data/data/Africa/Nouakchott.json +39 -0
- data/data/Africa/Ouagadougou.json +21 -0
- data/data/Africa/Porto-Novo.json +30 -0
- data/data/Africa/Sao_Tome.json +30 -0
- data/data/Africa/Tripoli.json +273 -0
- data/data/Africa/Tunis.json +318 -0
- data/data/Africa/Windhoek.json +1083 -0
- data/data/America/Adak.json +1569 -0
- data/data/America/Anchorage.json +1551 -0
- data/data/America/Anguilla.json +21 -0
- data/data/America/Antigua.json +30 -0
- data/data/America/Araguaina.json +453 -0
- data/data/America/Argentina/Buenos_Aires.json +543 -0
- data/data/America/Argentina/Catamarca.json +525 -0
- data/data/America/Argentina/Cordoba.json +525 -0
- data/data/America/Argentina/Jujuy.json +525 -0
- data/data/America/Argentina/La_Rioja.json +552 -0
- data/data/America/Argentina/Mendoza.json +534 -0
- data/data/America/Argentina/Rio_Gallegos.json +543 -0
- data/data/America/Argentina/Salta.json +507 -0
- data/data/America/Argentina/San_Juan.json +552 -0
- data/data/America/Argentina/San_Luis.json +543 -0
- data/data/America/Argentina/Tucuman.json +543 -0
- data/data/America/Argentina/Ushuaia.json +543 -0
- data/data/America/Aruba.json +30 -0
- data/data/America/Asuncion.json +1407 -0
- data/data/America/Atikokan.json +75 -0
- data/data/America/Bahia.json +543 -0
- data/data/America/Bahia_Banderas.json +1083 -0
- data/data/America/Barbados.json +102 -0
- data/data/America/Belem.json +273 -0
- data/data/America/Belize.json +507 -0
- data/data/America/Blanc-Sablon.json +66 -0
- data/data/America/Boa_Vista.json +309 -0
- data/data/America/Bogota.json +48 -0
- data/data/America/Boise.json +1605 -0
- data/data/America/Cambridge_Bay.json +1344 -0
- data/data/America/Campo_Grande.json +1398 -0
- data/data/America/Cancun.json +1029 -0
- data/data/America/Caracas.json +48 -0
- data/data/America/Cayenne.json +30 -0
- data/data/America/Cayman.json +30 -0
- data/data/America/Chicago.json +2406 -0
- data/data/America/Chihuahua.json +1065 -0
- data/data/America/Costa_Rica.json +102 -0
- data/data/America/Cuiaba.json +1380 -0
- data/data/America/Curacao.json +30 -0
- data/data/America/Danmarkshavn.json +300 -0
- data/data/America/Dawson.json +1389 -0
- data/data/America/Dawson_Creek.json +543 -0
- data/data/America/Denver.json +1704 -0
- data/data/America/Detroit.json +1524 -0
- data/data/America/Dominica.json +21 -0
- data/data/America/Edmonton.json +1641 -0
- data/data/America/Eirunepe.json +300 -0
- data/data/America/El_Salvador.json +57 -0
- data/data/America/Fortaleza.json +363 -0
- data/data/America/Glace_Bay.json +1533 -0
- data/data/America/Godthab.json +1281 -0
- data/data/America/Goose_Bay.json +2109 -0
- data/data/America/Grand_Turk.json +1326 -0
- data/data/America/Grenada.json +21 -0
- data/data/America/Guadeloupe.json +21 -0
- data/data/America/Guatemala.json +93 -0
- data/data/America/Guayaquil.json +30 -0
- data/data/America/Guyana.json +48 -0
- data/data/America/Halifax.json +2334 -0
- data/data/America/Havana.json +1650 -0
- data/data/America/Hermosillo.json +147 -0
- data/data/America/Indiana/Indianapolis.json +1182 -0
- data/data/America/Indiana/Knox.json +1641 -0
- data/data/America/Indiana/Marengo.json +1200 -0
- data/data/America/Indiana/Petersburg.json +1299 -0
- data/data/America/Indiana/Tell_City.json +1173 -0
- data/data/America/Indiana/Vevay.json +993 -0
- data/data/America/Indiana/Vincennes.json +1173 -0
- data/data/America/Indiana/Winamac.json +1227 -0
- data/data/America/Inuvik.json +1326 -0
- data/data/America/Iqaluit.json +1335 -0
- data/data/America/Jamaica.json +210 -0
- data/data/America/Juneau.json +1560 -0
- data/data/America/Kentucky/Louisville.json +1884 -0
- data/data/America/Kentucky/Monticello.json +1587 -0
- data/data/America/La_Paz.json +39 -0
- data/data/America/Lima.json +156 -0
- data/data/America/Los_Angeles.json +1938 -0
- data/data/America/Maceio.json +381 -0
- data/data/America/Managua.json +156 -0
- data/data/America/Manaus.json +291 -0
- data/data/America/Marigot.json +21 -0
- data/data/America/Martinique.json +48 -0
- data/data/America/Matamoros.json +1056 -0
- data/data/America/Mazatlan.json +1083 -0
- data/data/America/Menominee.json +1542 -0
- data/data/America/Merida.json +1029 -0
- data/data/America/Mexico_City.json +1137 -0
- data/data/America/Miquelon.json +1191 -0
- data/data/America/Moncton.json +2163 -0
- data/data/America/Monterrey.json +1047 -0
- data/data/America/Montevideo.json +1434 -0
- data/data/America/Montreal.json +2379 -0
- data/data/America/Montserrat.json +21 -0
- data/data/America/Nassau.json +1596 -0
- data/data/America/New_York.json +2406 -0
- data/data/America/Nipigon.json +1461 -0
- data/data/America/Nome.json +1569 -0
- data/data/America/Noronha.json +363 -0
- data/data/America/North_Dakota/Center.json +1596 -0
- data/data/America/North_Dakota/New_Salem.json +1596 -0
- data/data/America/Ojinaga.json +1074 -0
- data/data/America/Panama.json +30 -0
- data/data/America/Pangnirtung.json +1344 -0
- data/data/America/Paramaribo.json +57 -0
- data/data/America/Phoenix.json +120 -0
- data/data/America/Port-au-Prince.json +336 -0
- data/data/America/Port_of_Spain.json +21 -0
- data/data/America/Porto_Velho.json +273 -0
- data/data/America/Puerto_Rico.json +48 -0
- data/data/America/Rainy_River.json +1461 -0
- data/data/America/Rankin_Inlet.json +1317 -0
- data/data/America/Recife.json +363 -0
- data/data/America/Regina.json +489 -0
- data/data/America/Resolute.json +1326 -0
- data/data/America/Rio_Branco.json +282 -0
- data/data/America/Santa_Isabel.json +1632 -0
- data/data/America/Santarem.json +282 -0
- data/data/America/Santiago.json +1668 -0
- data/data/America/Santo_Domingo.json +165 -0
- data/data/America/Sao_Paulo.json +1398 -0
- data/data/America/Scoresbysund.json +1281 -0
- data/data/America/Shiprock.json +1704 -0
- data/data/America/St_Barthelemy.json +21 -0
- data/data/America/St_Johns.json +2424 -0
- data/data/America/St_Kitts.json +21 -0
- data/data/America/St_Lucia.json +30 -0
- data/data/America/St_Thomas.json +21 -0
- data/data/America/St_Vincent.json +30 -0
- data/data/America/Swift_Current.json +228 -0
- data/data/America/Tegucigalpa.json +75 -0
- data/data/America/Thule.json +1101 -0
- data/data/America/Thunder_Bay.json +1524 -0
- data/data/America/Tijuana.json +1641 -0
- data/data/America/Toronto.json +2370 -0
- data/data/America/Tortola.json +21 -0
- data/data/America/Vancouver.json +1965 -0
- data/data/America/Whitehorse.json +1389 -0
- data/data/America/Winnipeg.json +1929 -0
- data/data/America/Yakutat.json +1560 -0
- data/data/America/Yellowknife.json +1353 -0
- data/data/Antarctica/Casey.json +39 -0
- data/data/Antarctica/Davis.json +57 -0
- data/data/Antarctica/DumontDUrville.json +39 -0
- data/data/Antarctica/Macquarie.json +867 -0
- data/data/Antarctica/Mawson.json +30 -0
- data/data/Antarctica/McMurdo.json +1398 -0
- data/data/Antarctica/Palmer.json +1362 -0
- data/data/Antarctica/Rothera.json +21 -0
- data/data/Antarctica/South_Pole.json +1398 -0
- data/data/Antarctica/Syowa.json +21 -0
- data/data/Antarctica/Vostok.json +21 -0
- data/data/Arctic/Longyearbyen.json +1497 -0
- data/data/Asia/Aden.json +21 -0
- data/data/Asia/Almaty.json +444 -0
- data/data/Asia/Amman.json +1317 -0
- data/data/Asia/Anadyr.json +1299 -0
- data/data/Asia/Aqtau.json +453 -0
- data/data/Asia/Aqtobe.json +444 -0
- data/data/Asia/Ashgabat.json +246 -0
- data/data/Asia/Baghdad.json +498 -0
- data/data/Asia/Bahrain.json +30 -0
- data/data/Asia/Baku.json +1245 -0
- data/data/Asia/Bangkok.json +30 -0
- data/data/Asia/Beirut.json +1515 -0
- data/data/Asia/Bishkek.json +480 -0
- data/data/Asia/Brunei.json +30 -0
- data/data/Asia/Choibalsan.json +426 -0
- data/data/Asia/Chongqing.json +138 -0
- data/data/Asia/Colombo.json +84 -0
- data/data/Asia/Damascus.json +1605 -0
- data/data/Asia/Dhaka.json +84 -0
- data/data/Asia/Dili.json +57 -0
- data/data/Asia/Dubai.json +21 -0
- data/data/Asia/Dushanbe.json +228 -0
- data/data/Asia/Gaza.json +1542 -0
- data/data/Asia/Harbin.json +165 -0
- data/data/Asia/Ho_Chi_Minh.json +48 -0
- data/data/Asia/Hong_Kong.json +633 -0
- data/data/Asia/Hovd.json +426 -0
- data/data/Asia/Irkutsk.json +1308 -0
- data/data/Asia/Istanbul.json +1794 -0
- data/data/Asia/Jakarta.json +84 -0
- data/data/Asia/Jayapura.json +39 -0
- data/data/Asia/Jerusalem.json +1299 -0
- data/data/Asia/Kabul.json +30 -0
- data/data/Asia/Kamchatka.json +1299 -0
- data/data/Asia/Karachi.json +111 -0
- data/data/Asia/Kashgar.json +147 -0
- data/data/Asia/Kathmandu.json +30 -0
- data/data/Asia/Kolkata.json +57 -0
- data/data/Asia/Krasnoyarsk.json +1299 -0
- data/data/Asia/Kuala_Lumpur.json +84 -0
- data/data/Asia/Kuching.json +183 -0
- data/data/Asia/Kuwait.json +21 -0
- data/data/Asia/Macau.json +390 -0
- data/data/Asia/Magadan.json +1299 -0
- data/data/Asia/Makassar.json +48 -0
- data/data/Asia/Manila.json +102 -0
- data/data/Asia/Muscat.json +21 -0
- data/data/Asia/Nicosia.json +1389 -0
- data/data/Asia/Novokuznetsk.json +1299 -0
- data/data/Asia/Novosibirsk.json +1299 -0
- data/data/Asia/Omsk.json +1299 -0
- data/data/Asia/Oral.json +453 -0
- data/data/Asia/Phnom_Penh.json +48 -0
- data/data/Asia/Pontianak.json +84 -0
- data/data/Asia/Pyongyang.json +66 -0
- data/data/Asia/Qatar.json +30 -0
- data/data/Asia/Qyzylorda.json +453 -0
- data/data/Asia/Rangoon.json +48 -0
- data/data/Asia/Riyadh.json +21 -0
- data/data/Asia/Sakhalin.json +1308 -0
- data/data/Asia/Samarkand.json +219 -0
- data/data/Asia/Seoul.json +129 -0
- data/data/Asia/Shanghai.json +174 -0
- data/data/Asia/Singapore.json +93 -0
- data/data/Asia/Taipei.json +381 -0
- data/data/Asia/Tashkent.json +228 -0
- data/data/Asia/Tbilisi.json +462 -0
- data/data/Asia/Tehran.json +912 -0
- data/data/Asia/Thimphu.json +30 -0
- data/data/Asia/Tokyo.json +111 -0
- data/data/Asia/Ulaanbaatar.json +426 -0
- data/data/Asia/Urumqi.json +138 -0
- data/data/Asia/Vientiane.json +48 -0
- data/data/Asia/Vladivostok.json +1299 -0
- data/data/Asia/Yakutsk.json +1299 -0
- data/data/Asia/Yekaterinburg.json +1299 -0
- data/data/Asia/Yerevan.json +1281 -0
- data/data/Atlantic/Azores.json +2235 -0
- data/data/Atlantic/Bermuda.json +1416 -0
- data/data/Atlantic/Canary.json +1308 -0
- data/data/Atlantic/Cape_Verde.json +48 -0
- data/data/Atlantic/Faroe.json +1281 -0
- data/data/Atlantic/Madeira.json +2235 -0
- data/data/Atlantic/Reykjavik.json +597 -0
- data/data/Atlantic/South_Georgia.json +21 -0
- data/data/Atlantic/St_Helena.json +30 -0
- data/data/Atlantic/Stanley.json +1362 -0
- data/data/Australia/Adelaide.json +1533 -0
- data/data/Australia/Brisbane.json +165 -0
- data/data/Australia/Broken_Hill.json +1542 -0
- data/data/Australia/Currie.json +1524 -0
- data/data/Australia/Darwin.json +102 -0
- data/data/Australia/Eucla.json +183 -0
- data/data/Australia/Hobart.json +1596 -0
- data/data/Australia/Lindeman.json +201 -0
- data/data/Australia/Lord_Howe.json +1281 -0
- data/data/Australia/Melbourne.json +1524 -0
- data/data/Australia/Perth.json +183 -0
- data/data/Australia/Sydney.json +1524 -0
- data/data/CET.json +1470 -0
- data/data/CST6CDT.json +1587 -0
- data/data/EET.json +1344 -0
- data/data/EST.json +12 -0
- data/data/EST5EDT.json +1587 -0
- data/data/Etc/GMT+0.json +12 -0
- data/data/Etc/GMT+1.json +12 -0
- data/data/Etc/GMT+10.json +12 -0
- data/data/Etc/GMT+11.json +12 -0
- data/data/Etc/GMT+12.json +12 -0
- data/data/Etc/GMT+2.json +12 -0
- data/data/Etc/GMT+3.json +12 -0
- data/data/Etc/GMT+4.json +12 -0
- data/data/Etc/GMT+5.json +12 -0
- data/data/Etc/GMT+6.json +12 -0
- data/data/Etc/GMT+7.json +12 -0
- data/data/Etc/GMT+8.json +12 -0
- data/data/Etc/GMT+9.json +12 -0
- data/data/Etc/GMT-0.json +12 -0
- data/data/Etc/GMT-1.json +12 -0
- data/data/Etc/GMT-10.json +12 -0
- data/data/Etc/GMT-11.json +12 -0
- data/data/Etc/GMT-12.json +12 -0
- data/data/Etc/GMT-13.json +12 -0
- data/data/Etc/GMT-14.json +12 -0
- data/data/Etc/GMT-2.json +12 -0
- data/data/Etc/GMT-3.json +12 -0
- data/data/Etc/GMT-4.json +12 -0
- data/data/Etc/GMT-5.json +12 -0
- data/data/Etc/GMT-6.json +12 -0
- data/data/Etc/GMT-7.json +12 -0
- data/data/Etc/GMT-8.json +12 -0
- data/data/Etc/GMT-9.json +12 -0
- data/data/Etc/GMT.json +12 -0
- data/data/Etc/GMT0.json +12 -0
- data/data/Etc/Greenwich.json +12 -0
- data/data/Etc/UCT.json +12 -0
- data/data/Etc/UTC.json +12 -0
- data/data/Etc/Universal.json +12 -0
- data/data/Etc/Zulu.json +12 -0
- data/data/Europe/Amsterdam.json +1857 -0
- data/data/Europe/Andorra.json +1200 -0
- data/data/Europe/Athens.json +1479 -0
- data/data/Europe/Belgrade.json +1299 -0
- data/data/Europe/Berlin.json +1533 -0
- data/data/Europe/Bratislava.json +1524 -0
- data/data/Europe/Brussels.json +1884 -0
- data/data/Europe/Bucharest.json +1452 -0
- data/data/Europe/Budapest.json +1605 -0
- data/data/Europe/Chisinau.json +1488 -0
- data/data/Europe/Copenhagen.json +1452 -0
- data/data/Europe/Dublin.json +2271 -0
- data/data/Europe/Gibraltar.json +2037 -0
- data/data/Europe/Guernsey.json +2424 -0
- data/data/Europe/Helsinki.json +1308 -0
- data/data/Europe/Isle_of_Man.json +2424 -0
- data/data/Europe/Istanbul.json +1794 -0
- data/data/Europe/Jersey.json +2424 -0
- data/data/Europe/Kaliningrad.json +1425 -0
- data/data/Europe/Kiev.json +1308 -0
- data/data/Europe/Lisbon.json +2235 -0
- data/data/Europe/Ljubljana.json +1299 -0
- data/data/Europe/London.json +2424 -0
- data/data/Europe/Luxembourg.json +1884 -0
- data/data/Europe/Madrid.json +1722 -0
- data/data/Europe/Malta.json +1749 -0
- data/data/Europe/Mariehamn.json +1308 -0
- data/data/Europe/Minsk.json +1326 -0
- data/data/Europe/Monaco.json +1911 -0
- data/data/Europe/Moscow.json +1416 -0
- data/data/Europe/Nicosia.json +1389 -0
- data/data/Europe/Oslo.json +1497 -0
- data/data/Europe/Paris.json +1893 -0
- data/data/Europe/Podgorica.json +1299 -0
- data/data/Europe/Prague.json +1524 -0
- data/data/Europe/Riga.json +1371 -0
- data/data/Europe/Rome.json +1776 -0
- data/data/Europe/Samara.json +1308 -0
- data/data/Europe/San_Marino.json +1776 -0
- data/data/Europe/Sarajevo.json +1299 -0
- data/data/Europe/Simferopol.json +1308 -0
- data/data/Europe/Skopje.json +1299 -0
- data/data/Europe/Sofia.json +1362 -0
- data/data/Europe/Stockholm.json +1326 -0
- data/data/Europe/Tallinn.json +1344 -0
- data/data/Europe/Tirane.json +1425 -0
- data/data/Europe/Uzhgorod.json +1326 -0
- data/data/Europe/Vaduz.json +1281 -0
- data/data/Europe/Vatican.json +1776 -0
- data/data/Europe/Vienna.json +1479 -0
- data/data/Europe/Vilnius.json +1317 -0
- data/data/Europe/Volgograd.json +1290 -0
- data/data/Europe/Warsaw.json +1713 -0
- data/data/Europe/Zagreb.json +1299 -0
- data/data/Europe/Zaporozhye.json +1335 -0
- data/data/Europe/Zurich.json +1326 -0
- data/data/GMT.json +12 -0
- data/data/HST.json +12 -0
- data/data/Indian/Antananarivo.json +39 -0
- data/data/Indian/Chagos.json +30 -0
- data/data/Indian/Christmas.json +21 -0
- data/data/Indian/Cocos.json +21 -0
- data/data/Indian/Comoro.json +21 -0
- data/data/Indian/Kerguelen.json +21 -0
- data/data/Indian/Mahe.json +21 -0
- data/data/Indian/Maldives.json +30 -0
- data/data/Indian/Mauritius.json +57 -0
- data/data/Indian/Mayotte.json +21 -0
- data/data/Indian/Reunion.json +21 -0
- data/data/LICENSE +21 -0
- data/data/MET.json +1470 -0
- data/data/MST.json +12 -0
- data/data/MST7MDT.json +1587 -0
- data/data/PST8PDT.json +1587 -0
- data/data/Pacific/Apia.json +57 -0
- data/data/Pacific/Auckland.json +1650 -0
- data/data/Pacific/Chatham.json +1398 -0
- data/data/Pacific/Chuuk.json +21 -0
- data/data/Pacific/Easter.json +1533 -0
- data/data/Pacific/Efate.json +201 -0
- data/data/Pacific/Enderbury.json +39 -0
- data/data/Pacific/Fakaofo.json +21 -0
- data/data/Pacific/Fiji.json +93 -0
- data/data/Pacific/Funafuti.json +21 -0
- data/data/Pacific/Galapagos.json +30 -0
- data/data/Pacific/Gambier.json +21 -0
- data/data/Pacific/Guadalcanal.json +21 -0
- data/data/Pacific/Guam.json +39 -0
- data/data/Pacific/Honolulu.json +75 -0
- data/data/Pacific/Johnston.json +12 -0
- data/data/Pacific/Kiritimati.json +39 -0
- data/data/Pacific/Kosrae.json +39 -0
- data/data/Pacific/Kwajalein.json +39 -0
- data/data/Pacific/Majuro.json +30 -0
- data/data/Pacific/Marquesas.json +21 -0
- data/data/Pacific/Midway.json +57 -0
- data/data/Pacific/Nauru.json +48 -0
- data/data/Pacific/Niue.json +39 -0
- data/data/Pacific/Norfolk.json +30 -0
- data/data/Pacific/Noumea.json +75 -0
- data/data/Pacific/Pago_Pago.json +57 -0
- data/data/Pacific/Palau.json +21 -0
- data/data/Pacific/Pitcairn.json +30 -0
- data/data/Pacific/Pohnpei.json +21 -0
- data/data/Pacific/Ponape.json +21 -0
- data/data/Pacific/Port_Moresby.json +30 -0
- data/data/Pacific/Rarotonga.json +246 -0
- data/data/Pacific/Saipan.json +48 -0
- data/data/Pacific/Tahiti.json +21 -0
- data/data/Pacific/Tarawa.json +21 -0
- data/data/Pacific/Tongatapu.json +84 -0
- data/data/Pacific/Truk.json +21 -0
- data/data/Pacific/Wake.json +21 -0
- data/data/Pacific/Wallis.json +21 -0
- data/data/WET.json +1344 -0
- data/lib/timezone/version.rb +3 -0
- data/lib/timezone.rb +105 -0
- data/test/timezone_test.rb +55 -0
- data/timezone.gemspec +23 -0
- metadata +525 -0
data/lib/timezone.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'date'
|
3
|
+
require 'time'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
class Timezone
|
7
|
+
attr_accessor :rules, :zone
|
8
|
+
|
9
|
+
# Configuration class for the Timezone gem.
|
10
|
+
#
|
11
|
+
# Timezone::Configure.begin do |c| ... end
|
12
|
+
# c.username = username - the geonames username you use to access the geonames timezone API.
|
13
|
+
#
|
14
|
+
# Signup for a geonames username at http://www.geonames.org/login. Use that username to configure
|
15
|
+
# your application for latitude and longitude based timezone searches. If you aren't going to
|
16
|
+
# initialize timezone objects based on latitude and longitude then this configuration is not necessary.
|
17
|
+
class Configure
|
18
|
+
def self.username
|
19
|
+
@@username
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.username= username
|
23
|
+
@@username = username
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.begin
|
27
|
+
yield self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Error messages that can be raised by this gem. To catch any related error message, simply use Error::Base.
|
32
|
+
#
|
33
|
+
# begin
|
34
|
+
# ...
|
35
|
+
# rescue Timezone::Error::Base => e
|
36
|
+
# puts "Timezone Error: #{e.message}"
|
37
|
+
# end
|
38
|
+
module Error
|
39
|
+
class Base < StandardError; end
|
40
|
+
class InvalidZone < Base; end
|
41
|
+
class NilZone < Base; end
|
42
|
+
class GeoNames < Base; end
|
43
|
+
class ParseTime < Base; end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Create a new Timezone object.
|
47
|
+
#
|
48
|
+
# Timezone.new(options)
|
49
|
+
# :zone - The actual name of the zone. For example, Australia/Sydney or Americas/Los_Angeles.
|
50
|
+
# :lat, :lon - The latitude and longitude of the location.
|
51
|
+
# :latlon - The array of latitude and longitude of the location.
|
52
|
+
#
|
53
|
+
# If a latitude and longitude is passed in, the Timezone object will do a lookup for the actual zone
|
54
|
+
# name and then use that as a reference. It will then load the appropriate json timezone information
|
55
|
+
# for that zone, and compile a list of the timezone rules.
|
56
|
+
def initialize options
|
57
|
+
if options.has_key?(:lat) && options.has_key?(:lon)
|
58
|
+
options[:zone] = timezone_id options[:lat], options[:lon]
|
59
|
+
elsif options.has_key?(:latlon)
|
60
|
+
options[:zone] = timezone_id *options[:latlon]
|
61
|
+
end
|
62
|
+
|
63
|
+
raise Error::NilZone, 'No zone was found. Please specify a zone.' if options[:zone].nil?
|
64
|
+
|
65
|
+
file = File.join File.expand_path(File.dirname(__FILE__)+'/../data'), "#{options[:zone]}.json"
|
66
|
+
raise Error::InvalidZone, "'#{options[:zone]}' is not a valid zone." unless File.exists?(file)
|
67
|
+
|
68
|
+
data = JSON.parse(open(file).read)
|
69
|
+
@rules = data['zone']
|
70
|
+
@zone = data['_zone'] || options[:zone]
|
71
|
+
end
|
72
|
+
|
73
|
+
# Determine the time in the timezone.
|
74
|
+
#
|
75
|
+
# timezone.time(reference)
|
76
|
+
# reference - The Time you want to convert.
|
77
|
+
#
|
78
|
+
# The reference is converted to a UTC equivalent. That UTC equivalent is then used to lookup the appropriate
|
79
|
+
# offset in the timezone rules. Once the offset has been found that offset is added to the reference UTC time
|
80
|
+
# to calculate the reference time in the timezone.
|
81
|
+
def time reference
|
82
|
+
reference = reference.utc
|
83
|
+
rule = rules.detect{ |rule| _parsetime(rule['_from']) <= reference && _parsetime(rule['_to']) >= reference }
|
84
|
+
reference + rule['offset']
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def timezone_id lat, lon #:nodoc:
|
90
|
+
begin
|
91
|
+
response = Net::HTTP.get('ws.geonames.org', "/timezoneJSON?lat=#{lat}&lng=#{lon}&username=#{Configure.username}")
|
92
|
+
JSON.parse(response)['timezoneId']
|
93
|
+
rescue Exception => e
|
94
|
+
raise Error::GeoNames, e.message
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def _parsetime time #:nodoc:
|
99
|
+
begin
|
100
|
+
Time.strptime(time, "%Y-%m-%dT%H:%M:%SZ")
|
101
|
+
rescue Exception => e
|
102
|
+
raise Error::ParseTime, e.message
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/timezone')
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TimezoneTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_valid_timezone
|
7
|
+
assert_nothing_raised do
|
8
|
+
Timezone.new :zone => 'Australia/Sydney'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_nil_timezone
|
13
|
+
assert_raise Timezone::Error::NilZone do
|
14
|
+
Timezone.new :zone => nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_invalid_timezone
|
19
|
+
assert_raise Timezone::Error::InvalidZone do
|
20
|
+
Timezone.new :zone => 'Foo/Bar'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_loading_GMT_timezone
|
25
|
+
timezone = Timezone.new :zone => 'GMT'
|
26
|
+
assert_equal Time.now.utc.to_i, timezone.time(Time.now).to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_loading_historical_time
|
30
|
+
timezone = Timezone.new :zone => 'America/Los_Angeles'
|
31
|
+
local = Time.strptime('2011-02-11T13:20:00Z', '%Y-%m-%dT%H:%M:%SZ')
|
32
|
+
utc = Time.strptime('2011-02-11T21:20:00Z', '%Y-%m-%dT%H:%M:%SZ')
|
33
|
+
assert_equal local.to_i, timezone.time(utc).to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_loading_half_hour_timezone
|
37
|
+
timezone = Timezone.new :zone => 'Asia/Kathmandu'
|
38
|
+
utc = Time.utc(2011, 1, 4, 3, 51, 29)
|
39
|
+
local = Time.utc(2011, 1, 4, 9, 36, 29)
|
40
|
+
assert_equal local.to_i, timezone.time(utc).to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_using_lat_lon_coordinates
|
44
|
+
Timezone::Configure.begin { |c| c.username = 'timezone' }
|
45
|
+
timezone = Timezone.new :latlon => [-34.92771808058, 138.477041423321]
|
46
|
+
assert_equal 'Australia/Adelaide', timezone.zone
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_australian_timezone_with_dst
|
50
|
+
timezone = Timezone.new :zone => 'Australia/Adelaide'
|
51
|
+
utc = Time.utc(2010, 12, 23, 19, 37, 15)
|
52
|
+
local = Time.utc(2010, 12, 24, 6, 7, 15)
|
53
|
+
assert_equal local.to_i, timezone.time(utc).to_i
|
54
|
+
end
|
55
|
+
end
|
data/timezone.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "timezone/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "timezone"
|
7
|
+
s.version = Timezone::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Pan Thomakos"]
|
10
|
+
s.email = ["pan.thomakos@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/panthomakos/timezone"
|
12
|
+
s.summary = "timezone-#{Timezone::VERSION}"
|
13
|
+
s.description = %q{A simple way to get accurate current and historical timezone information based on zone or latitude and longitude coordinates. This gem uses the tz database (http://www.twinsun.com/tz/tz-link.htm) for historical timezone information. It also uses the geonames API for timezone latitude and longitude lookup (http://www.geonames.org/export/web-services.html).}
|
14
|
+
|
15
|
+
s.rubyforge_project = "timezone"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.extra_rdoc_files = ['README.markdown', 'License.txt']
|
21
|
+
s.rdoc_options = ['--charset=UTF-8']
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|