mirror of https://github.com/espruino/BangleApps
commit
0a30374b5d
19
apps.json
19
apps.json
|
@ -5132,6 +5132,25 @@
|
|||
{"name":"ltherm.img","url":"icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "ftclock",
|
||||
"name": "Four Twenty Clock",
|
||||
"version": "0.01",
|
||||
"description": "A clock that tells when and where it's going to be 4:20 next",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}, {"url":"screenshot1.png"}],
|
||||
"type": "clock",
|
||||
"tags": "clock",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"allow_emulator": true,
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"ftclock.app.js","url":"app.js"},
|
||||
{"name":"fourTwenty","url":"fourTwenty.js"},
|
||||
{"name":"fourTwentyTz","url":"fourTwentyTz.js"},
|
||||
{"name":"ftclock.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "mmind",
|
||||
"name": "Classic Mind Game",
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
timezonedb.csv.zip
|
||||
country.csv
|
||||
zone.csv
|
||||
timezone.csv
|
|
@ -0,0 +1 @@
|
|||
0.01: first release
|
|
@ -0,0 +1,24 @@
|
|||
# Four Twenty Clock
|
||||
|
||||
A clock that tells when and where it's going to be [4:20](https://en.wikipedia.org/wiki/420_%28cannabis_culture%29) next
|
||||
|
||||
 
|
||||
|
||||
## Generating `fourTwentyTz.js`
|
||||
|
||||
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
|
||||
|
||||
[Nimrod Kerrett](zzzen.com)
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwghC/AH4A/AH4A/AAMHu4ACuwHBs4HDsEGBIQLCsADBgwPDCAQGEuwXFBwI0GEAMHuAGCCoMHC4pMHEAIXEAgIGEBwI9BC4wSCC8IVCMAwIBs4XKUQJfITQgXCDwp8EHAqaECoLFEu4cDBIggBs6uFZozuGBAVmC4g+FMgZQEZQ5vGC4iRIC5IrDN4h5EC5J3BCoIKGgyaEC44VBC46yEDgoeDgxqLC5SCMAgoTFY47GFC4xFBdwwPBD4oWFAH4A/AH4A/AH4AjA=="))
|
|
@ -0,0 +1,52 @@
|
|||
let getNextFourTwenty = require("fourTwenty").getNextFourTwenty;
|
||||
require("FontTeletext10x18Ascii").add(Graphics);
|
||||
let leaf_img = "\x17\x18\x81\x00\x00\x10\x00\x00 \x00\x00@\x00\x01\xc0\x00\x03\x80\x00\x0f\x80\x00\x1f\x00\x00>\x00\x00|\x00\xc0\xf8\x19\xe1\xf0\xf1\xe3\xe3\xc3\xf7\xdf\x83\xff\xfe\x03\xff\xf8\x03\xff\xe0\x03\xff\x80\x03\xfe\x00\x7f\xff\xc0\xff\xff\xc0\x06\xe0\x00\x18\xc0\x00 \x80\x00\x00\x00";
|
||||
|
||||
// timeout used to update every minute
|
||||
let drawTimeout;
|
||||
|
||||
// schedule a draw for the next minute
|
||||
function queueDraw() {
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw();
|
||||
}, 60000 - (Date.now() % 60000));
|
||||
}
|
||||
|
||||
|
||||
function draw() {
|
||||
g.reset();
|
||||
g.setBgColor("#ffffff");
|
||||
let date = new Date();
|
||||
let timeStr = require("locale").time(date,1);
|
||||
let next420 = getNextFourTwenty();
|
||||
g.clearRect(0,26,g.getWidth(),g.getHeight());
|
||||
g.setColor("#00ff00").setFontAlign(0,-1).setFont("Teletext10x18Ascii",2);
|
||||
g.drawString(next420.minutes? timeStr: `\0${leaf_img}${timeStr}\0${leaf_img}`, g.getWidth()/2, 28);
|
||||
g.setColor("#000000");
|
||||
g.setFontAlign(-1,-1).setFont("Teletext10x18Ascii");
|
||||
g.drawString(g.wrapString(next420.text, g.getWidth()-8).join("\n"),4,60);
|
||||
|
||||
// queue draw in one minute
|
||||
queueDraw();
|
||||
}
|
||||
|
||||
// Clear the screen once, at startup
|
||||
g.clear();
|
||||
// Load widgets
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
// draw immediately at first, queue update
|
||||
draw();
|
||||
// Stop updates when LCD is off, restart when on
|
||||
Bangle.on('lcdPower',on=>{
|
||||
if (on) {
|
||||
draw(); // draw immediately, queue redraw
|
||||
} else { // stop draw timer
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = undefined;
|
||||
}
|
||||
});
|
||||
// Show launcher when middle button pressed
|
||||
Bangle.setUI("clock");
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -0,0 +1,45 @@
|
|||
let timezones = require("fourTwentyTz").timezones;
|
||||
|
||||
function get420offset() {
|
||||
let current_time = Math.floor((Date.now()%(24*3600*1000))/60000);
|
||||
let current_min = current_time%60;
|
||||
if (current_min>20 && current_min<25) {
|
||||
current_time -= current_min-20; // 5 minutes grace period
|
||||
}
|
||||
let offset = 16*60+20-current_time;
|
||||
if (offset<0) {
|
||||
offset += 24*60;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
function makeFourTwentyText(minutes, places) {
|
||||
//let plural = minutes==1? "": "s";
|
||||
//let msgprefix = minutes? `${minutes} minute${plural} to`: "It is now";
|
||||
let msgprefix = minutes? `${minutes}m to`: "It is now";
|
||||
let msgsuffix = places.length>1? ", and other fine places": "";
|
||||
let msgplace = places[Math.floor(Math.random()*places.length)];
|
||||
return `${msgprefix} 4:20 at ${msgplace}${msgsuffix}.`;
|
||||
}
|
||||
|
||||
function getNextFourTwenty() {
|
||||
let offs = get420offset();
|
||||
for (let i=0; i<timezones.length; i++) {
|
||||
if (timezones[i][0]<=offs) {
|
||||
let minutes = offs-timezones[i][0];
|
||||
let places = timezones[i][1];
|
||||
return {
|
||||
minutes: minutes,
|
||||
places: places,
|
||||
text: makeFourTwentyText(minutes, places)
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
minutes: 666,
|
||||
places: ["Snafu (Yes. It's a bug)"],
|
||||
text: "Snafu (Yes. It's a bug)"
|
||||
};
|
||||
}
|
||||
|
||||
exports.getNextFourTwenty = getNextFourTwenty;
|
|
@ -0,0 +1,463 @@
|
|||
// Generated by mkFourTwentyTz.js
|
||||
// Data source: https://timezonedb.com/files/timezonedb.csv.zip
|
||||
// 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"
|
||||
]
|
||||
}
|
|
@ -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<now && (!("starttime" in zone) || zone.starttime<starttime)) {
|
||||
zone.starttime = starttime;
|
||||
zone.offs = Math.floor(offs/60);
|
||||
}
|
||||
})
|
||||
.on('end', () => {
|
||||
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.');
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "mkfourtwentytz",
|
||||
"version": "1.0.0",
|
||||
"description": "Convert timezonedb.com CSV to fourTwentyTz.js for BangleJS ftclock app",
|
||||
"main": "mkFourTwentyTz.js",
|
||||
"scripts": {
|
||||
"make": "node mkFourTwentyTz.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"csv": "^6.0.5"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Loading…
Reference in New Issue