From 231271a94f01ad2bd566a86d975f8f2df5063d1c Mon Sep 17 00:00:00 2001 From: RKBoss6 Date: Thu, 19 Jun 2025 15:49:45 -0400 Subject: [PATCH] Add files via upload --- apps/worldclkinfo/README.md | 27 +++ apps/worldclkinfo/app.png | Bin 0 -> 7211 bytes apps/worldclkinfo/clkinfo.js | 280 ++++++++++++++++++++++++++++++++ apps/worldclkinfo/metadata.json | 17 ++ apps/worldclkinfo/settings.js | 45 +++++ 5 files changed, 369 insertions(+) create mode 100644 apps/worldclkinfo/README.md create mode 100644 apps/worldclkinfo/app.png create mode 100644 apps/worldclkinfo/clkinfo.js create mode 100644 apps/worldclkinfo/metadata.json create mode 100644 apps/worldclkinfo/settings.js diff --git a/apps/worldclkinfo/README.md b/apps/worldclkinfo/README.md new file mode 100644 index 000000000..837b4e422 --- /dev/null +++ b/apps/worldclkinfo/README.md @@ -0,0 +1,27 @@ +# World Clock Info +A clock info that creates a new ClockInfo list for world clocks, so you can see the time across the world. + +## Usage +Use a clock with ClockInfo, then swipe left/right to get to the World Clock list. From there, swipe up/down to get to the city you want. + +## Cities +* London +* Mumbai +* New York City +* Tokyo +* Dubai +* Los Angeles +* Paris + + +To add any more, consider contacting [RKBoss6](https://github.com/RKBoss6) on github, or fork it and modify the app yourself. +## Settings +In app settings, there is a small section for World Clock Info +#### Shorten Cities +This shortens the city name (New York City --> NYC) to fit inside smaller ClockInfos. +#### Show Meridians +This shows meridians, if you enable them in locale. Otherwise, it will not show no matter what setting it is set to. +#### Shorten Meridians +This shortens the meridian and removes the space separating it from the time (3:50 pm --> 3:50p) to fit inside smaller ClockInfos. +## Creator +[RKBoss6](https://github.com/RKBoss6) diff --git a/apps/worldclkinfo/app.png b/apps/worldclkinfo/app.png new file mode 100644 index 0000000000000000000000000000000000000000..3e3c79899f17e0affbca5db7f697ab1c5541f6d8 GIT binary patch literal 7211 zcmeHMc{G&m`yXjRlr2PM8bym)nHh#b*^&m?qhwZwVaCibBV;Q}q*RhDMMMZC*_UkT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z zRTQi`J`FU!hXit}?QH31<_LjH!!_(^ux&G|pJY%Y1CU1PvoxTs`SO zFttf5T?er`zxRmeXY^K{avf`Zy1m_(zUHMvHplRN{k_ndx!^s8^AZWczypcNsi202 zxX$B;b^Rgngp$8avXR@a0uj&#W%*ay99FNJCAR9&qIYJU5;4yME?wOZIK^y z;&rtt2|z7vmbvXzmWCuTT;t)J*V9ZF+mOUw{%Z4hoX^ZI zBKlW!VXJCQRDt95%-rUWk$|a)Z%@)AnG)6h1kd7np5&YfaU`wb7T0mSahJE=SQx*Pp&%pWG1d|!{0>!Eipx27Ljser$%NzO^0_7Ye()RjZ z?ZO5woN_^58oGU7T3o4!D;$hyqMj*Uw^Gi+=jEIG3K790iFjI-w+3rQY{k5kT{XeT r+wX;!T!&BU{g8tLQwcTRleJJam8!BwEZ`>@5Xj8f!l+=cYuNt)BO2^? literal 0 HcmV?d00001 diff --git a/apps/worldclkinfo/clkinfo.js b/apps/worldclkinfo/clkinfo.js new file mode 100644 index 000000000..f65bd3f2d --- /dev/null +++ b/apps/worldclkinfo/clkinfo.js @@ -0,0 +1,280 @@ + +(function() { + + + //read settings + var settings = Object.assign({ + // default values + shorten: true, + showMeridians: true, + shortenMeridians:false, + }, require("Storage").readJSON("worldclkinfosettings.json", true) || {}); + + //All offsets from UTC in minutes. Positive: behind UTC. Negative: Ahead of UTC. + + const londonTimeOffset=60; + const mumbaiTimeOffset=330; + const nycTimeOffset=-240; + const tokyoTimeOffset=540; + const dubaiTimeOffset=240; + const laTimeOffset=-420; + const parisTimeOffset=120; + + + + function getWorldDateString(cityName){ + //Gets difference between UTC and local time + var date=new Date(); + var currOffset = date.getTimezoneOffset(); + + var timeOffset; + + switch (cityName) { + case "London": + timeOffset=londonTimeOffset; + break; + case "Mumbai": + timeOffset=mumbaiTimeOffset; + break; + case "New York": + timeOffset=nycTimeOffset; + break; + case "Tokyo": + timeOffset=tokyoTimeOffset; + break; + case "Dubai": + timeOffset=dubaiTimeOffset; + break; + case "Los Angeles": + timeOffset=laTimeOffset; + break; + case "Paris": + timeOffset=parisTimeOffset; + break; + + default: + //Nothing else matches + timeOffset=0 + + } + + //go to UTC time + date.setMinutes(date.getMinutes() + currOffset); + //from there, go to city time + date.setMinutes(date.getMinutes() + timeOffset); + + var meridian=require("locale").meridian(date); + + var clockStr; + if(settings.showMeridians==true){ + if(settings.shortenMeridians==true){ + //get A - am, or P - pm + clockStr = require("locale").time(date, 1 /*omit seconds*/)+meridian[0]; + + }else{ + clockStr = require("locale").time(date, 1 /*omit seconds*/)+" "+meridian; + } + + }else{ + + clockStr = require("locale").time(date, 1 /*omit seconds*/); + + } + + + var finalCityStr; + + if(settings.shorten==true){ + + switch (cityName) { + case "Los Angeles": + finalCityStr="LA"; + break; + case "New York": + finalCityStr="NYC"; + break; + default: + //Nothing else matches + finalCityStr=cityName; + } + }else{ + + finalCityStr=cityName; + + + } + + + + var finalStr=finalCityStr+"\n"+clockStr; + return finalStr; + + + } + + + + + + return { + name: "World Clocks", + items: [ + + { name : "London", + get : () => { + return { + text : getWorldDateString("London"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + + { name : "Mumbai", + get : () => { + return { + text : getWorldDateString("Mumbai"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + + { name : "New York", + get : () => { + return { + text : getWorldDateString("New York"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + + { name : "Tokyo", + get : () => { + return { + text : getWorldDateString("Tokyo"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + + { name : "Dubai", + get : () => { + return { + text : getWorldDateString("Dubai"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + { name : "Los Angeles", + get : () => { + return { + text : getWorldDateString("Los Angeles"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + }, + + { name : "Paris", + get : () => { + return { + text : getWorldDateString("Paris"), + //blank image + img : atob("") + }; + }, + show : function() { + this.interval = setTimeout(()=>{ + this.emit("redraw"); + this.interval = setInterval(()=>{ + this.emit("redraw"); + }, 60000); + }, 60000 - (Date.now() % 60000)); + }, + hide : function() { + clearInterval(this.interval); + this.interval = undefined; + } + } + + + + ] + }; +}) diff --git a/apps/worldclkinfo/metadata.json b/apps/worldclkinfo/metadata.json new file mode 100644 index 000000000..f725827a5 --- /dev/null +++ b/apps/worldclkinfo/metadata.json @@ -0,0 +1,17 @@ +{ "id": "worldclkinfo", + "name": "World Clock Info", + "version": "0.05", + "description": "Creates a ClockInfo List to view times around the world (London, Hong Kong, Delhi, New York, etc.)", + "icon": "app.png", + "type": "clkinfo", + "tags": "clkinfo", + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"worldclkinfo.clkinfo.js","url":"clkinfo.js"}, + {"name":"worldclkinfo.settings.js","url":"settings.js"} + ], + "data": [ + {"name":"worldclkinfosettings.json"} + ] +} diff --git a/apps/worldclkinfo/settings.js b/apps/worldclkinfo/settings.js new file mode 100644 index 000000000..7b78ed32c --- /dev/null +++ b/apps/worldclkinfo/settings.js @@ -0,0 +1,45 @@ +(function(back) { + var FILE = "worldclkinfosettings.json"; + // Load settings + var settings = Object.assign({ + shorten: false, + showMeridians:true, + shortenMeridians:false, + }, require('Storage').readJSON(FILE, true) || {}); + + function writeSettings() { + require('Storage').writeJSON(FILE, settings); + } + + // Show the menu + E.showMenu({ + "" : { "title" : "World ClockInfo" }, + "< Back" : () => back(), + + 'Shorten Cities ': { + value: !!settings.shorten, // !! converts undefined to false + onchange: v => { + settings.shorten = v; + writeSettings(); + } + + }, + 'Show Meridians': { + value: !!settings.showMeridians, // !! converts undefined to false + onchange: v => { + settings.showMeridians = v; + writeSettings(); + } + + }, + 'Shorten Meridians': { + value: !!settings.shortenMeridians, // !! converts undefined to false + onchange: v => { + settings.shortenMeridians = v; + writeSettings(); + } + + }, + + }); +});