diff --git a/apps/hworldclock/ChangeLog b/apps/hworldclock/ChangeLog index 8a2c0fec4..a4bd84390 100644 --- a/apps/hworldclock/ChangeLog +++ b/apps/hworldclock/ChangeLog @@ -6,4 +6,4 @@ 0.20: Add theme support 0.21: Add Settings 0.22: Use default Bangle formatter for booleans -0.23: Small fixes +0.23: Added note to configure position in "my location" if not done yet. Small fixes. diff --git a/apps/hworldclock/README.md b/apps/hworldclock/README.md index 0f4f9296c..170a2aa8b 100644 --- a/apps/hworldclock/README.md +++ b/apps/hworldclock/README.md @@ -8,6 +8,8 @@ If watch is locked, seconds get refreshed every 10 seconds. ## Usage +Location for sun set / rise set with mylocation app. + Provide names and the UTC offsets for up to three other timezones in the app store. These are stored in a json file on your watch. UTC offsets can be decimal (e.g., 5.5 for India). The clock does not handle summer time / daylight saving time changes automatically. If one of your three locations changes its UTC offset, you can simply change the setting in the app store and update. Currently the clock only supports 24 hour time format for the additional time zones. @@ -21,11 +23,5 @@ Please use [the Espruino Forum](http://forum.espruino.com/microcosms/1424/) if y Created by Hank. -Based on the great work of -================= -World Clock - 4 time zones -Made by [Scott Hale](https://www.github.com/computermacgyver), based upon the [Simple Clock](https://github.com/espruino/BangleApps/tree/master/apps/sclock). -===== a n d ===== -Sun Clock -[Sun Clock](https://github.com/espruino/BangleApps/tree/master/apps/sunclock) -================= +Based on the great work of "World Clock - 4 time zones". Made by [Scott Hale](https://www.github.com/computermacgyver), based upon the [Simple Clock](https://github.com/espruino/BangleApps/tree/master/apps/sclock). +And Sun Clock [Sun Clock](https://github.com/espruino/BangleApps/tree/master/apps/sunclock) \ No newline at end of file diff --git a/apps/hworldclock/app.js b/apps/hworldclock/app.js index f7444d319..b634f3f9c 100644 --- a/apps/hworldclock/app.js +++ b/apps/hworldclock/app.js @@ -46,8 +46,8 @@ setting = require("Storage").readJSON("setting.json",1); E.setTimeZone(setting.timezone); // timezone = 1 for MEZ, = 2 for MESZ SunCalc = require("hsuncalc.js"); const LOCATION_FILE = "mylocation.json"; -var rise = "07:00"; -var set = "20:00"; +var rise = null; +var set = null; //var pos = {altitude: 20, azimuth: 135}; //var noonpos = {altitude: 37, azimuth: 180}; //=======Sun @@ -137,12 +137,17 @@ function getCurrentTimeFromOffset(dt, offset) { } function updatePos() { - coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":53.3,"lon":10.1,"location":"Pattensen"}; + coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":0,"lon":0,"location":"-"}; //{"lat":53.3,"lon":10.1,"location":"Pattensen"}; + if (coord.lat != 0 && coord.lon != 0) { //pos = SunCalc.getPosition(Date.now(), coord.lat, coord.lon); times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon); - rise = times.sunrise.toString().split(" ")[4].substr(0,5); - set = times.sunset.toString().split(" ")[4].substr(0,5); + rise = "^" + times.sunrise.toString().split(" ")[4].substr(0,5); + set = "v" + times.sunset.toString().split(" ")[4].substr(0,5); //noonpos = SunCalc.getPosition(times.solarNoon, coord.lat, coord.lon); + } else { + rise = null; + set = null; + } } @@ -266,8 +271,12 @@ function draw() { }); if (showSunInfo) { - g.setFontAlign(-1, 0).setFont("Vector",12).drawString(`^${rise}`, 10, 3 + yposWorld + 3 * 15, true); // draw riseset - g.setFontAlign(1, 0).drawString(`v${set}`, xcol2, 3 + yposWorld + 3 * 15, true); // draw riseset + if (rise != null){ + g.setFontAlign(-1, 0).setFont("Vector",12).drawString(`${rise}`, 10, 3 + yposWorld + 3 * 15, true); // draw riseset + g.setFontAlign(1, 0).drawString(`${set}`, xcol2, 3 + yposWorld + 3 * 15, true); // draw riseset + } else { + g.setFontAlign(-1, 0).setFont("Vector",11).drawString("set city in \'my location\' app!", 10, 3 + yposWorld + 3 * 15, true); + } } //debug settings //g.setFontAlign(1, 0); diff --git a/apps/hworldclock/custom.html b/apps/hworldclock/custom.html index 896d999f5..3e6d0b901 100644 --- a/apps/hworldclock/custom.html +++ b/apps/hworldclock/custom.html @@ -30,8 +30,8 @@ } } catch(e){ offsets=[ - [true,"London",0], - [true,"NY",-5], + [true,"London",1], + [true,"NY",-4], [true, "Denver",-6], ];