diff --git a/apps/ftclock/.gitignore b/apps/ftclock/.gitignore new file mode 100644 index 000000000..b384cf1f2 --- /dev/null +++ b/apps/ftclock/.gitignore @@ -0,0 +1,4 @@ +timezonedb.csv.zip +country.csv +zone.csv +timezone.csv diff --git a/apps/ftclock/README.md b/apps/ftclock/README.md index 665a7693d..f30151552 100644 --- a/apps/ftclock/README.md +++ b/apps/ftclock/README.md @@ -4,12 +4,20 @@ A clock that tells when and where it's going to be [4:20](https://en.wikipedia.o ![screensot](screenshot.png) ![screenshot at 4:20](screenshot1.png) -## Note +## Generating `fourTwentyTz.js` -Once in a while, there'd be updates to the [timezone database](https://timezonedb.com/download) which -would require updating `fourTwentyTz.js`. I'll do my best to release a new version every time this happens, -but if you ever need to do this yourself, just run `python mkFourTwentyTz.py` (after downloading the timezone CSV files. -See comment at the top of the script). +Once in a while we need to regenerate it for 2 reasons: + +* One or more places got in or out of daylight saving time (DST) mode. +* The database saying _when_ places enter/exit DST mode got updated. + +I'll do my best to release a new version every time this happens, +but if you ever need to do this yourself, here's how: + +* `cd` to the `ftclock` folder +* If you haven't done so yet, run `npm install` there (this would create the `node_modules` folder). +* Get and unzip the latest `timezone.csv.zip` from https://timezonedb.com/download +* Run `npm run make` ## Creator diff --git a/apps/ftclock/fourTwentyTz.js b/apps/ftclock/fourTwentyTz.js index e41f3fdd0..cebab42cb 100644 --- a/apps/ftclock/fourTwentyTz.js +++ b/apps/ftclock/fourTwentyTz.js @@ -1,536 +1,463 @@ -// Generated by mk420tz.py - see https://github.com/thedod/BangleApps/420clock -// (version: Sat Dec 18 10:17:32 2021) +// Generated by mkFourTwentyTz.js // Data source: https://timezonedb.com/files/timezonedb.csv.zip -// (version: Sat Oct 16 01:48:14 2021) -exports.timezones = [ - [ - 1380, - [ - "Azores, Portugal", - "Cape Verde, Cabo Verde", - "Scoresbysund, Greenland" - ] - ], - [ - 1320, - [ - "Noronha, Brazil", - "South Georgia, South Georgia and the South Sandwich Islands" - ] - ], - [ - 1260, - [ - "Araguaina, Brazil", - "Asuncion, Paraguay", - "Bahia, Brazil", - "Belem, Brazil", - "Buenos Aires, Argentina", - "Catamarca, Argentina", - "Cayenne, French Guiana", - "Cordoba, Argentina", - "Fortaleza, Brazil", - "Jujuy, Argentina", - "La Rioja, Argentina", - "Maceio, Brazil", - "Mendoza, Argentina", - "Miquelon, Saint Pierre and Miquelon", - "Montevideo, Uruguay", - "Nuuk, Greenland", - "Palmer, Antarctica", - "Paramaribo, Suriname", - "Punta Arenas, Chile", - "Recife, Brazil", - "Rio Gallegos, Argentina", - "Rothera, Antarctica", - "Salta, Argentina", - "San Juan, Argentina", - "San Luis, Argentina", - "Santarem, Brazil", - "Santiago, Chile", - "Sao Paulo, Brazil", - "Stanley, Falkland Islands (Malvinas)", - "Tucuman, Argentina", - "Ushuaia, Argentina" - ] - ], - [ - 1200, - [ - "Anguilla, AI", - "Antigua, Antigua and Barbuda", - "Aruba, AW", - "Barbados, BB", - "Bermuda, BM", - "Blanc-Sablon, Canada", - "Boa Vista, Brazil", - "Campo Grande, Brazil", - "Caracas, Venezuela (Bolivarian Republic of)", - "Cuiaba, Brazil", - "Curacao, Cura\u00e7ao", - "Dominica, DM", - "Glace Bay, Canada", - "Goose Bay, Canada", - "Grenada, GD", - "Guadeloupe, GP", - "Guyana, GY", - "Halifax, Canada", - "Kralendijk, Bonaire, Sint Eustatius and Saba", - "La Paz, Bolivia (Plurinational State of)", - "Lower Princes, Sint Maarten (Dutch part)", - "Manaus, Brazil", - "Marigot, Saint Martin (French part)", - "Martinique, MQ", - "Moncton, Canada", - "Montserrat, MS", - "Port of Spain, Trinidad and Tobago", - "Porto Velho, Brazil", - "Puerto Rico, PR", - "Santo Domingo, Dominican Republic", - "St Barthelemy, Saint Barth\u00e9lemy", - "St Kitts, Saint Kitts and Nevis", - "St Lucia, Saint Lucia", - "St Thomas, Virgin Islands (U.S.)", - "St Vincent, Saint Vincent and the Grenadines", - "Thule, Greenland", - "Tortola, Virgin Islands (British)" - ] - ], - [ - 1140, - [ - "Atikokan, Canada", - "Bogota, Colombia", - "Cancun, Mexico", - "Cayman, Cayman Islands", - "Detroit, United States of America", - "Easter, Chile", - "Eirunepe, Brazil", - "Grand Turk, Turks and Caicos Islands", - "Guayaquil, Ecuador", - "Havana, Cuba", - "Indianapolis, Indiana", - "Iqaluit, Canada", - "Jamaica, JM", - "Lima, Peru", - "Louisville, Kentucky", - "Marengo, Indiana", - "Monticello, Kentucky", - "Nassau, Bahamas", - "New York, United States of America", - "Nipigon, Canada", - "Panama, PA", - "Pangnirtung, Canada", - "Petersburg, Indiana", - "Port-au-Prince, Haiti", - "Rio Branco, Brazil", - "Thunder Bay, Canada", - "Toronto, Canada", - "Vevay, Indiana", - "Vincennes, Indiana", - "Winamac, Indiana" - ] - ], - [ - 1080, - [ - "Bahia Banderas, Mexico", - "Belize, BZ", - "Beulah, North Dakota", - "Center, North Dakota", - "Chicago, United States of America", - "Costa Rica, CR", - "El Salvador, SV", - "Galapagos, Ecuador", - "Guatemala, GT", - "Knox, Indiana", - "Managua, Nicaragua", - "Matamoros, Mexico", - "Menominee, United States of America", - "Merida, Mexico", - "Mexico City, Mexico", - "Monterrey, Mexico", - "New Salem, North Dakota", - "Rainy River, Canada", - "Rankin Inlet, Canada", - "Regina, Canada", - "Resolute, Canada", - "Swift Current, Canada", - "Tegucigalpa, Honduras", - "Tell City, Indiana", - "Winnipeg, Canada" - ] - ], - [ - 1020, - [ - "Boise, United States of America", - "Cambridge Bay, Canada", - "Chihuahua, Mexico", - "Creston, Canada", - "Dawson Creek, Canada", - "Dawson, Canada", - "Denver, United States of America", - "Edmonton, Canada", - "Fort Nelson, Canada", - "Hermosillo, Mexico", - "Inuvik, Canada", - "Mazatlan, Mexico", - "Ojinaga, Mexico", - "Phoenix, United States of America", - "Whitehorse, Canada", - "Yellowknife, Canada" - ] - ], - [ - 960, - [ - "Los Angeles, United States of America", - "Pitcairn, PN", - "Tijuana, Mexico", - "Vancouver, Canada" - ] - ], - [ - 900, - [ - "Anchorage, United States of America", - "Gambier, French Polynesia", - "Juneau, United States of America", - "Metlakatla, United States of America", - "Nome, United States of America", - "Sitka, United States of America", - "Yakutat, United States of America" - ] - ], - [ - 840, - [ - "Adak, United States of America", - "Honolulu, United States of America", - "Kiritimati, Kiribati", - "Rarotonga, Cook Islands", - "Tahiti, French Polynesia" - ] - ], - [ - 780, - [ - "Apia, Samoa", - "Auckland, New Zealand", - "Fakaofo, Tokelau", - "Kanton, Kiribati", - "McMurdo, Antarctica", - "Midway, United States Minor Outlying Islands", - "Niue, NU", - "Pago Pago, American Samoa", - "Tongatapu, Tonga" - ] - ], - [ - 720, - [ - "Anadyr, Russian Federation", - "Fiji, FJ", - "Funafuti, Tuvalu", - "Kamchatka, Russian Federation", - "Kwajalein, Marshall Islands", - "Majuro, Marshall Islands", - "Nauru, NR", - "Norfolk, Norfolk Island", - "Tarawa, Kiribati", - "Wake, United States Minor Outlying Islands", - "Wallis, Wallis and Futuna" - ] - ], - [ - 660, - [ - "Bougainville, Papua New Guinea", - "Casey, Antarctica", - "Efate, Vanuatu", - "Guadalcanal, Solomon Islands", - "Hobart, Australia", - "Kosrae, Micronesia (Federated States of)", - "Lord Howe, Australia", - "Macquarie, Australia", - "Magadan, Russian Federation", - "Melbourne, Australia", - "Noumea, New Caledonia", - "Pohnpei, Micronesia (Federated States of)", - "Sakhalin, Russian Federation", - "Srednekolymsk, Russian Federation", - "Sydney, Australia" - ] - ], - [ - 600, - [ - "Brisbane, Australia", - "Chuuk, Micronesia (Federated States of)", - "DumontDUrville, Antarctica", - "Guam, GU", - "Lindeman, Australia", - "Port Moresby, Papua New Guinea", - "Saipan, Northern Mariana Islands", - "Ust-Nera, Russian Federation", - "Vladivostok, Russian Federation" - ] - ], - [ - 540, - [ - "Chita, Russian Federation", - "Dili, Timor-Leste", - "Jayapura, Indonesia", - "Khandyga, Russian Federation", - "Palau, PW", - "Pyongyang, Korea (Democratic People's Republic of)", - "Seoul, Korea, Republic of", - "Tokyo, Japan", - "Yakutsk, Russian Federation" - ] - ], - [ - 480, - [ - "Brunei, Brunei Darussalam", - "Choibalsan, Mongolia", - "Hong Kong, HK", - "Irkutsk, Russian Federation", - "Kuala Lumpur, Malaysia", - "Kuching, Malaysia", - "Macau, Macao", - "Makassar, Indonesia", - "Manila, Philippines", - "Perth, Australia", - "Shanghai, China", - "Singapore, SG", - "Taipei, Taiwan, Province of China", - "Ulaanbaatar, Mongolia" - ] - ], - [ - 420, - [ - "Bangkok, Thailand", - "Barnaul, Russian Federation", - "Christmas, Christmas Island", - "Davis, Antarctica", - "Ho Chi Minh, Viet Nam", - "Hovd, Mongolia", - "Jakarta, Indonesia", - "Krasnoyarsk, Russian Federation", - "Novokuznetsk, Russian Federation", - "Novosibirsk, Russian Federation", - "Phnom Penh, Cambodia", - "Pontianak, Indonesia", - "Tomsk, Russian Federation", - "Vientiane, Lao People's Democratic Republic" - ] - ], - [ - 360, - [ - "Almaty, Kazakhstan", - "Bishkek, Kyrgyzstan", - "Chagos, British Indian Ocean Territory", - "Dhaka, Bangladesh", - "Omsk, Russian Federation", - "Qostanay, Kazakhstan", - "Thimphu, Bhutan", - "Urumqi, China", - "Vostok, Antarctica" - ] - ], - [ - 300, - [ - "Aqtau, Kazakhstan", - "Aqtobe, Kazakhstan", - "Ashgabat, Turkmenistan", - "Atyrau, Kazakhstan", - "Dushanbe, Tajikistan", - "Karachi, Pakistan", - "Kerguelen, French Southern Territories", - "Maldives, MV", - "Mawson, Antarctica", - "Oral, Kazakhstan", - "Qyzylorda, Kazakhstan", - "Samarkand, Uzbekistan", - "Tashkent, Uzbekistan", - "Yekaterinburg, Russian Federation" - ] - ], - [ - 240, - [ - "Astrakhan, Russian Federation", - "Baku, Azerbaijan", - "Dubai, United Arab Emirates", - "Mahe, Seychelles", - "Mauritius, MU", - "Muscat, Oman", - "Reunion, R\u00e9union", - "Samara, Russian Federation", - "Saratov, Russian Federation", - "Tbilisi, Georgia", - "Ulyanovsk, Russian Federation", - "Yerevan, Armenia" - ] - ], - [ - 180, - [ - "Addis Ababa, Ethiopia", - "Aden, Yemen", - "Antananarivo, Madagascar", - "Asmara, Eritrea", - "Baghdad, Iraq", - "Bahrain, BH", - "Comoro, Comoros", - "Dar es Salaam, Tanzania, United Republic of", - "Djibouti, DJ", - "Istanbul, Turkey", - "Kampala, Uganda", - "Kirov, Russian Federation", - "Kuwait, KW", - "Mayotte, YT", - "Minsk, Belarus", - "Mogadishu, Somalia", - "Moscow, Russian Federation", - "Nairobi, Kenya", - "Qatar, QA", - "Riyadh, Saudi Arabia", - "Simferopol, Ukraine", - "Syowa, Antarctica", - "Volgograd, Russian Federation" - ] - ], - [ - 120, - [ - "Amman, Jordan", - "Athens, Greece", - "Beirut, Lebanon", - "Blantyre, Malawi", - "Bucharest, Romania", - "Bujumbura, Burundi", - "Cairo, Egypt", - "Chisinau, Moldova, Republic of", - "Damascus, Syrian Arab Republic", - "Famagusta, Cyprus", - "Gaborone, Botswana", - "Gaza, Palestine, State of", - "Harare, Zimbabwe", - "Hebron, Palestine, State of", - "Helsinki, Finland", - "Jerusalem, Israel", - "Johannesburg, South Africa", - "Juba, South Sudan", - "Kaliningrad, Russian Federation", - "Khartoum, Sudan", - "Kiev, Ukraine", - "Kigali, Rwanda", - "Lubumbashi, Congo, Democratic Republic of the", - "Lusaka, Zambia", - "Maputo, Mozambique", - "Mariehamn, \u00c5land Islands", - "Maseru, Lesotho", - "Mbabane, Eswatini", - "Nicosia, Cyprus", - "Riga, Latvia", - "Sofia, Bulgaria", - "Tallinn, Estonia", - "Tripoli, Libya", - "Uzhgorod, Ukraine", - "Vilnius, Lithuania", - "Windhoek, Namibia", - "Zaporozhye, Ukraine" - ] - ], - [ - 60, - [ - "Algiers, Algeria", - "Amsterdam, Netherlands", - "Andorra, AD", - "Bangui, Central African Republic", - "Belgrade, Serbia", - "Berlin, Germany", - "Bratislava, Slovakia", - "Brazzaville, Congo", - "Brussels, Belgium", - "Budapest, Hungary", - "Busingen, Germany", - "Casablanca, Morocco", - "Ceuta, Spain", - "Copenhagen, Denmark", - "Douala, Cameroon", - "El Aaiun, Western Sahara", - "Gibraltar, GI", - "Kinshasa, Congo, Democratic Republic of the", - "Lagos, Nigeria", - "Libreville, Gabon", - "Ljubljana, Slovenia", - "Longyearbyen, Svalbard and Jan Mayen", - "Luanda, Angola", - "Luxembourg, LU", - "Madrid, Spain", - "Malabo, Equatorial Guinea", - "Malta, MT", - "Monaco, MC", - "Ndjamena, Chad", - "Niamey, Niger", - "Oslo, Norway", - "Paris, France", - "Podgorica, Montenegro", - "Porto-Novo, Benin", - "Prague, Czechia", - "Rome, Italy", - "San Marino, SM", - "Sarajevo, Bosnia and Herzegovina", - "Skopje, North Macedonia", - "Stockholm, Sweden", - "Tirane, Albania", - "Tunis, Tunisia", - "Vaduz, Liechtenstein", - "Vatican, Holy See", - "Vienna, Austria", - "Warsaw, Poland", - "Zagreb, Croatia", - "Zurich, Switzerland" - ] - ], - [ - 0, - [ - "Abidjan, C\u00f4te d'Ivoire", - "Accra, Ghana", - "Bamako, Mali", - "Banjul, Gambia", - "Bissau, Guinea-Bissau", - "Canary, Spain", - "Conakry, Guinea", - "Dakar, Senegal", - "Danmarkshavn, Greenland", - "Dublin, Ireland", - "Faroe, Faroe Islands", - "Freetown, Sierra Leone", - "Guernsey, GG", - "Isle of Man, IM", - "Jersey, JE", - "Lisbon, Portugal", - "Lome, Togo", - "London, United Kingdom of Great Britain and Northern Ireland", - "Madeira, Portugal", - "Monrovia, Liberia", - "Nouakchott, Mauritania", - "Ouagadougou, Burkina Faso", - "Reykjavik, Iceland", - "Sao Tome, Sao Tome and Principe", - "St Helena, Saint Helena, Ascension and Tristan da Cunha", - "Troll, Antarctica" - ] - ] -]; +// Sun Jan 09 2022 13:21:47 GMT+0200 (Israel Standard Time) +exports.timezones = { + "0": [ + "Troll, Antarctica", + "Ouagadougou, Burkina Faso", + "Abidjan, Côte d'Ivoire", + "Canary, Spain", + "Faroe, Faroe Islands", + "London, United Kingdom of Great Britain and Northern Ireland", + "Guernsey, Guernsey", + "Accra, Ghana", + "Danmarkshavn, Greenland", + "Banjul, Gambia", + "Conakry, Guinea", + "Bissau, Guinea-Bissau", + "Dublin, Ireland", + "Isle of_Man, Isle of Man", + "Reykjavik, Iceland", + "Jersey, Jersey", + "Monrovia, Liberia", + "Bamako, Mali", + "Nouakchott, Mauritania", + "Lisbon, Portugal", + "Madeira, Portugal", + "St Helena, Saint Helena, Ascension and Tristan da Cunha", + "Freetown, Sierra Leone", + "Dakar, Senegal", + "Sao Tome, Sao Tome and Principe", + "Lome, Togo" + ], + "60": [ + "Andorra, Andorra", + "Tirane, Albania", + "Luanda, Angola", + "Vienna, Austria", + "Sarajevo, Bosnia and Herzegovina", + "Brussels, Belgium", + "Porto-Novo, Benin", + "Kinshasa, Congo, Democratic Republic of the", + "Bangui, Central African Republic", + "Brazzaville, Congo", + "Zurich, Switzerland", + "Douala, Cameroon", + "Prague, Czechia", + "Berlin, Germany", + "Busingen, Germany", + "Copenhagen, Denmark", + "Algiers, Algeria", + "El Aaiun, Western Sahara", + "Madrid, Spain", + "Ceuta, Spain", + "Paris, France", + "Libreville, Gabon", + "Gibraltar, Gibraltar", + "Malabo, Equatorial Guinea", + "Zagreb, Croatia", + "Budapest, Hungary", + "Rome, Italy", + "Vaduz, Liechtenstein", + "Luxembourg, Luxembourg", + "Casablanca, Morocco", + "Monaco, Monaco", + "Podgorica, Montenegro", + "Skopje, North Macedonia", + "Malta, Malta", + "Niamey, Niger", + "Lagos, Nigeria", + "Amsterdam, Netherlands", + "Oslo, Norway", + "Warsaw, Poland", + "Belgrade, Serbia", + "Stockholm, Sweden", + "Ljubljana, Slovenia", + "Longyearbyen, Svalbard and Jan Mayen", + "Bratislava, Slovakia", + "San Marino, San Marino", + "Ndjamena, Chad", + "Tunis, Tunisia", + "Vatican, Holy See" + ], + "120": [ + "Mariehamn, Åland Islands", + "Sofia, Bulgaria", + "Bujumbura, Burundi", + "Gaborone, Botswana", + "Lubumbashi, Congo, Democratic Republic of the", + "Nicosia, Cyprus", + "Famagusta, Cyprus", + "Tallinn, Estonia", + "Cairo, Egypt", + "Helsinki, Finland", + "Athens, Greece", + "Jerusalem, Israel", + "Amman, Jordan", + "Beirut, Lebanon", + "Maseru, Lesotho", + "Vilnius, Lithuania", + "Riga, Latvia", + "Tripoli, Libya", + "Chisinau, Moldova, Republic of", + "Blantyre, Malawi", + "Maputo, Mozambique", + "Windhoek, Namibia", + "Gaza, Palestine, State of", + "Hebron, Palestine, State of", + "Bucharest, Romania", + "Kaliningrad, Russian Federation", + "Kigali, Rwanda", + "Khartoum, Sudan", + "Juba, South Sudan", + "Damascus, Syrian Arab Republic", + "Mbabane, Eswatini", + "Kiev, Ukraine", + "Uzhgorod, Ukraine", + "Zaporozhye, Ukraine", + "Johannesburg, South Africa", + "Lusaka, Zambia", + "Harare, Zimbabwe" + ], + "180": [ + "Syowa, Antarctica", + "Bahrain, Bahrain", + "Minsk, Belarus", + "Djibouti, Djibouti", + "Asmara, Eritrea", + "Addis Ababa, Ethiopia", + "Baghdad, Iraq", + "Nairobi, Kenya", + "Comoro, Comoros", + "Kuwait, Kuwait", + "Antananarivo, Madagascar", + "Qatar, Qatar", + "Moscow, Russian Federation", + "Simferopol, Ukraine", + "Kirov, Russian Federation", + "Volgograd, Russian Federation", + "Riyadh, Saudi Arabia", + "Mogadishu, Somalia", + "Istanbul, Turkey", + "Dar es_Salaam, Tanzania, United Republic of", + "Kampala, Uganda", + "Aden, Yemen", + "Mayotte, Mayotte" + ], + "240": [ + "Dubai, United Arab Emirates", + "Yerevan, Armenia", + "Baku, Azerbaijan", + "Tbilisi, Georgia", + "Mauritius, Mauritius", + "Muscat, Oman", + "Reunion, Réunion", + "Astrakhan, Russian Federation", + "Saratov, Russian Federation", + "Ulyanovsk, Russian Federation", + "Samara, Russian Federation", + "Mahe, Seychelles" + ], + "300": [ + "Mawson, Antarctica", + "Qyzylorda, Kazakhstan", + "Aqtobe, Kazakhstan", + "Aqtau, Kazakhstan", + "Atyrau, Kazakhstan", + "Oral, Kazakhstan", + "Maldives, Maldives", + "Karachi, Pakistan", + "Yekaterinburg, Russian Federation", + "Kerguelen, French Southern Territories", + "Dushanbe, Tajikistan", + "Ashgabat, Turkmenistan", + "Samarkand, Uzbekistan", + "Tashkent, Uzbekistan" + ], + "360": [ + "Vostok, Antarctica", + "Dhaka, Bangladesh", + "Thimphu, Bhutan", + "Urumqi, China", + "Chagos, British Indian Ocean Territory", + "Bishkek, Kyrgyzstan", + "Almaty, Kazakhstan", + "Qostanay, Kazakhstan", + "Omsk, Russian Federation" + ], + "420": [ + "Davis, Antarctica", + "Christmas, Christmas Island", + "Jakarta, Indonesia", + "Pontianak, Indonesia", + "Phnom Penh, Cambodia", + "Vientiane, Lao People's Democratic Republic", + "Hovd, Mongolia", + "Novosibirsk, Russian Federation", + "Barnaul, Russian Federation", + "Tomsk, Russian Federation", + "Novokuznetsk, Russian Federation", + "Krasnoyarsk, Russian Federation", + "Bangkok, Thailand", + "Ho Chi_Minh, Viet Nam" + ], + "480": [ + "Perth, Australia", + "Brunei, Brunei Darussalam", + "Shanghai, China", + "Hong Kong, Hong Kong", + "Makassar, Indonesia", + "Ulaanbaatar, Mongolia", + "Choibalsan, Mongolia", + "Macau, Macao", + "Kuala Lumpur, Malaysia", + "Kuching, Malaysia", + "Manila, Philippines", + "Irkutsk, Russian Federation", + "Singapore, Singapore", + "Taipei, Taiwan, Province of China" + ], + "540": [ + "Jayapura, Indonesia", + "Tokyo, Japan", + "Pyongyang, Korea (Democratic People's Republic of)", + "Seoul, Korea, Republic of", + "Palau, Palau", + "Chita, Russian Federation", + "Yakutsk, Russian Federation", + "Khandyga, Russian Federation", + "Dili, Timor-Leste" + ], + "600": [ + "DumontDUrville, Antarctica", + "Brisbane, Australia", + "Lindeman, Australia", + "Chuuk, Micronesia (Federated States of)", + "Guam, Guam", + "Saipan, Northern Mariana Islands", + "Port Moresby, Papua New Guinea", + "Vladivostok, Russian Federation", + "Ust-Nera, Russian Federation" + ], + "660": [ + "Casey, Antarctica", + "Lord Howe, Australia", + "Macquarie, Australia", + "Hobart, Australia", + "Melbourne, Australia", + "Sydney, Australia", + "Pohnpei, Micronesia (Federated States of)", + "Kosrae, Micronesia (Federated States of)", + "Noumea, New Caledonia", + "Bougainville, Papua New Guinea", + "Magadan, Russian Federation", + "Sakhalin, Russian Federation", + "Srednekolymsk, Russian Federation", + "Guadalcanal, Solomon Islands", + "Efate, Vanuatu" + ], + "720": [ + "Tarawa, Kiribati", + "Majuro, Marshall Islands", + "Kwajalein, Marshall Islands", + "Norfolk, Norfolk Island", + "Nauru, Nauru", + "Kamchatka, Russian Federation", + "Anadyr, Russian Federation", + "Funafuti, Tuvalu", + "Wake, United States Minor Outlying Islands", + "Wallis, Wallis and Futuna" + ], + "780": [ + "McMurdo, Antarctica", + "Pago Pago, American Samoa", + "Fiji, Fiji", + "Kanton, Kiribati", + "Niue, Niue", + "Auckland, New Zealand", + "Fakaofo, Tokelau", + "Tongatapu, Tonga", + "Midway, United States Minor Outlying Islands", + "Apia, Samoa" + ], + "840": [ + "Rarotonga, Cook Islands", + "Kiritimati, Kiribati", + "Tahiti, French Polynesia", + "Adak, United States of America", + "Honolulu, United States of America" + ], + "900": [ + "Gambier, French Polynesia", + "Anchorage, United States of America", + "Juneau, United States of America", + "Sitka, United States of America", + "Metlakatla, United States of America", + "Yakutat, United States of America", + "Nome, United States of America" + ], + "960": [ + "Vancouver, Canada", + "Tijuana, Mexico", + "Pitcairn, Pitcairn", + "Los Angeles, United States of America" + ], + "1020": [ + "Edmonton, Canada", + "Cambridge Bay, Canada", + "Yellowknife, Canada", + "Inuvik, Canada", + "Creston, Canada", + "Dawson Creek, Canada", + "Fort Nelson, Canada", + "Whitehorse, Canada", + "Dawson, Canada", + "Mazatlan, Mexico", + "Chihuahua, Mexico", + "Ojinaga, Mexico", + "Hermosillo, Mexico", + "Denver, United States of America", + "Boise, United States of America", + "Phoenix, United States of America" + ], + "1080": [ + "Belize, Belize", + "Winnipeg, Canada", + "Rainy River, Canada", + "Resolute, Canada", + "Rankin Inlet, Canada", + "Regina, Canada", + "Swift Current, Canada", + "Costa Rica, Costa Rica", + "Galapagos, Ecuador", + "Guatemala, Guatemala", + "Tegucigalpa, Honduras", + "Mexico City, Mexico", + "Merida, Mexico", + "Monterrey, Mexico", + "Matamoros, Mexico", + "Bahia Banderas, Mexico", + "Managua, Nicaragua", + "El Salvador, El Salvador", + "Chicago, United States of America", + "Tell City, Indiana", + "Knox, Indiana", + "Menominee, United States of America", + "Center, North Dakota", + "New_Salem, North Dakota", + "Beulah, North Dakota" + ], + "1140": [ + "Eirunepe, Brazil", + "Rio Branco, Brazil", + "Nassau, Bahamas", + "Toronto, Canada", + "Nipigon, Canada", + "Thunder Bay, Canada", + "Iqaluit, Canada", + "Pangnirtung, Canada", + "Atikokan, Canada", + "Easter, Chile", + "Bogota, Colombia", + "Havana, Cuba", + "Guayaquil, Ecuador", + "Port-au-Prince, Haiti", + "Jamaica, Jamaica", + "Cayman, Cayman Islands", + "Cancun, Mexico", + "Panama, Panama", + "Lima, Peru", + "Grand Turk, Turks and Caicos Islands", + "New York, United States of America", + "Detroit, United States of America", + "Louisville, Kentucky", + "Monticello, Kentucky", + "Indianapolis, Indiana", + "Vincennes, Indiana", + "Winamac, Indiana", + "Marengo, Indiana", + "Petersburg, Indiana", + "Vevay, Indiana" + ], + "1200": [ + "Antigua, Antigua and Barbuda", + "Anguilla, Anguilla", + "Aruba, Aruba", + "Barbados, Barbados", + "St Barthelemy, Saint Barthélemy", + "Bermuda, Bermuda", + "La Paz, Bolivia (Plurinational State of)", + "Kralendijk, Bonaire, Sint Eustatius and Saba", + "Campo Grande, Brazil", + "Cuiaba, Brazil", + "Porto Velho, Brazil", + "Boa Vista, Brazil", + "Manaus, Brazil", + "Halifax, Canada", + "Glace Bay, Canada", + "Moncton, Canada", + "Goose Bay, Canada", + "Blanc-Sablon, Canada", + "Curacao, Curaçao", + "Dominica, Dominica", + "Santo Domingo, Dominican Republic", + "Grenada, Grenada", + "Thule, Greenland", + "Guadeloupe, Guadeloupe", + "Guyana, Guyana", + "St Kitts, Saint Kitts and Nevis", + "St Lucia, Saint Lucia", + "Marigot, Saint Martin (French part)", + "Martinique, Martinique", + "Montserrat, Montserrat", + "Puerto Rico, Puerto Rico", + "Lower Princes, Sint Maarten (Dutch part)", + "Port of_Spain, Trinidad and Tobago", + "St Vincent, Saint Vincent and the Grenadines", + "Caracas, Venezuela (Bolivarian Republic of)", + "Tortola, Virgin Islands (British)", + "St Thomas, Virgin Islands (U.S.)" + ], + "1260": [ + "Palmer, Antarctica", + "Rothera, Antarctica", + "Buenos Aires, Argentina", + "Cordoba, Argentina", + "Salta, Argentina", + "Jujuy, Argentina", + "Tucuman, Argentina", + "Catamarca, Argentina", + "La Rioja, Argentina", + "San Juan, Argentina", + "Mendoza, Argentina", + "San Luis, Argentina", + "Rio Gallegos, Argentina", + "Ushuaia, Argentina", + "Belem, Brazil", + "Fortaleza, Brazil", + "Recife, Brazil", + "Araguaina, Brazil", + "Maceio, Brazil", + "Bahia, Brazil", + "Sao Paulo, Brazil", + "Santarem, Brazil", + "Santiago, Chile", + "Punta Arenas, Chile", + "Stanley, Falkland Islands (Malvinas)", + "Cayenne, French Guiana", + "Nuuk, Greenland", + "Miquelon, Saint Pierre and Miquelon", + "Asuncion, Paraguay", + "Paramaribo, Suriname", + "Montevideo, Uruguay" + ], + "1320": [ + "Noronha, Brazil", + "South Georgia, South Georgia and the South Sandwich Islands" + ], + "1380": [ + "Cape Verde, Cabo Verde", + "Scoresbysund, Greenland", + "Azores, Portugal" + ] +} \ No newline at end of file diff --git a/apps/ftclock/mkFourTwentyTz.js b/apps/ftclock/mkFourTwentyTz.js new file mode 100644 index 000000000..dd199523a --- /dev/null +++ b/apps/ftclock/mkFourTwentyTz.js @@ -0,0 +1,74 @@ +let fs = require('fs'); +let csv = require('csv'); + +let countries = {}, + zones = {}, + offsdict = {}, + now = Date.now(); // we need this to find zone's current DST state + +function handleWrite(err,bytes) { + if (err) { + console.log(`Error writing to file ${err}`); + } +} + +console.log("Generating fourTwentyTz.js..."); +fs.createReadStream(__dirname+'/country.csv') + .pipe(csv.parse()) + .on('data', (r) => { + countries[r[0]] = r[1]; + }) + .on('end', () => { + fs.createReadStream(__dirname+'/zone.csv') + .pipe(csv.parse()) + .on('data', (r) => { + let parts = r[2].replace('_',' ').split('/'); + let city = parts[parts.length-1]; + let country =''; + if (parts.length>2) { // e.g. America/North_Dakota/New_Salem + country = parts[1]; // e.g. North Dakota + } else { + country = countries[r[1]]; // e.g. United States + } + zones[parseInt(r[0])] = {"name": `${city}, ${country}`}; + }) + .on('end', () => { + fs.createReadStream(__dirname+'/timezone.csv') + .pipe(csv.parse()) + .on('data', (r) => { + code = parseInt(r[0]); + if (!(code in zones)) return; + starttime = parseInt(r[2] || "0"); // Bugger. They're feeding us blanks for UTC now + offs = parseInt(r[3]); + if (offs<0) { + offs += 60*60*24; + } + zone = zones[code]; + if (starttime { + for (z in zones) { + zone = zones[z]; + if (zone.offs%60) continue; // One a dem funky timezones. Ignore. + zonelist = offsdict[zone.offs] || []; + zonelist.push(zone.name); + offsdict[zone.offs] = zonelist; + } + fs.open("fourTwentyTz.js","w", (err, fd) => { + if (err) { + console.log("Can't open output file"); + return; + } + fs.write(fd, "// Generated by mkFourTwentyTz.js\n", handleWrite); + fs.write(fd, `// ${Date()}\n`, handleWrite); + fs.write(fd, "// Data source: https://timezonedb.com/files/timezonedb.csv.zip\n", handleWrite); + fs.write(fd, "exports.timezones = ", handleWrite); + fs.write(fd, JSON.stringify(offsdict, null, 4), handleWrite); + console.log('Done.'); + }); + }) + }) + }); diff --git a/apps/ftclock/mkFourTwentyTz.py b/apps/ftclock/mkFourTwentyTz.py deleted file mode 100644 index 713b68059..000000000 --- a/apps/ftclock/mkFourTwentyTz.py +++ /dev/null @@ -1,46 +0,0 @@ -# Generates fourTwentyTz.js from time zone csv files -# get latest files from https://timezonedb.com/download -import csv,json,time,os,math -countries = {} -for r in csv.reader(open("country.csv")): - countries[r[0]] = r[1] -zones = {} -for r in csv.reader(open("zone.csv")): - parts = r[2].replace('_',' ').split('/') - city = parts[-1] - if len(parts)>2: # e.g. America/North_Dakota/New_Salem - country = parts[1] # e.g. North Dakota - else: # e.g. America/Denver - country = countries[r[1]] # e.g. United States - if country==city: # Avoid awkward searches like "Anguilla, Anguilla" - country = r[1] # Use code instead - zones[int(r[0])] = {"name":', '.join((city,country))} -now = int(time.time()) -for r in csv.reader(open("timezone.csv")): - code = int(r[0]) - if code not in zones: - continue - starttime = int(r[2] or "0") # Bugger. They're feeding us blanks for UTC now - offs = int(r[3]) - if offs < 0: - offs += 60*60*24 - d = zones[code] - if starttime