Merge pull request #1256 from DDDanny/antonclk-clock-0.05-showWeeknumber
Anton-Clock can optionally show ISO-8601 calendar weeknumbermaster
commit
99bfd0915c
|
|
@ -4242,7 +4242,7 @@
|
||||||
{
|
{
|
||||||
"id": "antonclk",
|
"id": "antonclk",
|
||||||
"name": "Anton Clock",
|
"name": "Anton Clock",
|
||||||
"version": "0.04",
|
"version": "0.05",
|
||||||
"description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.",
|
"description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.",
|
||||||
"readme":"README.md",
|
"readme":"README.md",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,6 @@
|
||||||
0.02: Load widgets after setUI so widclk knows when to hide
|
0.02: Load widgets after setUI so widclk knows when to hide
|
||||||
0.03: Clock now shows day of week under date.
|
0.03: Clock now shows day of week under date.
|
||||||
0.04: Clock can optionally show seconds, date optionally in ISO-8601 format, weekdays and uppercase configurable, too.
|
0.04: Clock can optionally show seconds, date optionally in ISO-8601 format, weekdays and uppercase configurable, too.
|
||||||
|
0.05: Clock can optionally show ISO-8601 calendar weeknumber (default: Off)
|
||||||
|
when weekday name "Off": week #:<num>
|
||||||
|
when weekday name "On": weekday name is cut at 6th position and .#<week num> is added
|
||||||
|
|
@ -40,8 +40,7 @@ The main menu contains several settings covering Anton clock in general.
|
||||||
* **Show Weekday** - Weekday is shown in the time presentation without seconds.
|
* **Show Weekday** - Weekday is shown in the time presentation without seconds.
|
||||||
Weekday name depends on the current locale.
|
Weekday name depends on the current locale.
|
||||||
If seconds are shown, the weekday is never shown as there is not enough space on the watch face.
|
If seconds are shown, the weekday is never shown as there is not enough space on the watch face.
|
||||||
* **Uppercase** - Weekday name and month name in the long format are converted to upper case letters.
|
**Show Weeknumber** - Weeknumber (ISO-8601) is shown.
|
||||||
This can improve readability.
|
|
||||||
* **Vector font** - Use the built-in vector font for dates and weekday.
|
* **Vector font** - Use the built-in vector font for dates and weekday.
|
||||||
This can improve readability.
|
This can improve readability.
|
||||||
Otherwise, a scaled version of the built-in 6x8 pixels font is used.
|
Otherwise, a scaled version of the built-in 6x8 pixels font is used.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ var secondsWithColon;
|
||||||
var dateOnMain;
|
var dateOnMain;
|
||||||
var dateOnSecs;
|
var dateOnSecs;
|
||||||
var weekDay;
|
var weekDay;
|
||||||
|
var calWeek;
|
||||||
var upperCase;
|
var upperCase;
|
||||||
var vectorFont;
|
var vectorFont;
|
||||||
|
|
||||||
|
|
@ -29,22 +30,25 @@ var secondsScreen = true;
|
||||||
|
|
||||||
var isBangle1 = (g.getWidth() == 240);
|
var isBangle1 = (g.getWidth() == 240);
|
||||||
|
|
||||||
/* For development purposes
|
//For development purposes
|
||||||
|
/*
|
||||||
require('Storage').writeJSON(SETTINGSFILE, {
|
require('Storage').writeJSON(SETTINGSFILE, {
|
||||||
secondsMode: "Always", // "Never", "Unlocked", "Always"
|
secondsMode: "Unlocked", // "Never", "Unlocked", "Always"
|
||||||
secondsColoured: true,
|
secondsColoured: true,
|
||||||
secondsWithColon: true,
|
secondsWithColon: true,
|
||||||
dateOnMain: "Long", // "Short", "Long", "ISO8601"
|
dateOnMain: "Long", // "Short", "Long", "ISO8601"
|
||||||
dateOnSecs: "Year", // "No", "Year", "Weekday", LEGACY: true/false
|
dateOnSecs: "Year", // "No", "Year", "Weekday", LEGACY: true/false
|
||||||
weekDay: true,
|
weekDay: true,
|
||||||
|
calWeek: true,
|
||||||
upperCase: true,
|
upperCase: true,
|
||||||
vectorFont: true,
|
vectorFont: true,
|
||||||
});
|
});
|
||||||
/* */
|
*/
|
||||||
|
|
||||||
/* OR (also for development purposes)
|
// OR (also for development purposes)
|
||||||
|
/*
|
||||||
require('Storage').erase(SETTINGSFILE);
|
require('Storage').erase(SETTINGSFILE);
|
||||||
/* */
|
*/
|
||||||
|
|
||||||
// Helper method for loading the settings
|
// Helper method for loading the settings
|
||||||
function def(value, def) {
|
function def(value, def) {
|
||||||
|
|
@ -60,6 +64,7 @@ function loadSettings() {
|
||||||
dateOnMain = def(settings.dateOnMain, "Long");
|
dateOnMain = def(settings.dateOnMain, "Long");
|
||||||
dateOnSecs = def(settings.dateOnSecs, "Year");
|
dateOnSecs = def(settings.dateOnSecs, "Year");
|
||||||
weekDay = def(settings.weekDay, true);
|
weekDay = def(settings.weekDay, true);
|
||||||
|
calWeek = def(settings.calWeek, false);
|
||||||
upperCase = def(settings.upperCase, true);
|
upperCase = def(settings.upperCase, true);
|
||||||
vectorFont = def(settings.vectorFont, false);
|
vectorFont = def(settings.vectorFont, false);
|
||||||
|
|
||||||
|
|
@ -99,6 +104,18 @@ function isoStr(date) {
|
||||||
return date.getFullYear() + "-" + ("0" + (date.getMonth() + 1)).substr(-2) + "-" + ("0" + date.getDate()).substr(-2);
|
return date.getFullYear() + "-" + ("0" + (date.getMonth() + 1)).substr(-2) + "-" + ("0" + date.getDate()).substr(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ISO8601calWeek(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
||||||
|
var tdt = new Date(date.valueOf());
|
||||||
|
var dayn = (date.getDay() + 6) % 7;
|
||||||
|
tdt.setDate(tdt.getDate() - dayn + 3);
|
||||||
|
var firstThursday = tdt.valueOf();
|
||||||
|
tdt.setMonth(0, 1);
|
||||||
|
if (tdt.getDay() !== 4) {
|
||||||
|
tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
|
||||||
|
}
|
||||||
|
return 1 + Math.ceil((firstThursday - tdt) / 604800000);
|
||||||
|
}
|
||||||
|
|
||||||
function doColor() {
|
function doColor() {
|
||||||
return !isBangle1 && !Bangle.isLocked() && secondsColoured;
|
return !isBangle1 && !Bangle.isLocked() && secondsColoured;
|
||||||
}
|
}
|
||||||
|
|
@ -169,11 +186,14 @@ function draw() {
|
||||||
else
|
else
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.drawString(dateStr, x, y);
|
g.drawString(dateStr, x, y);
|
||||||
if (weekDay) {
|
if (weekDay || calWeek) {
|
||||||
var dowStr = require("locale").dow(date);
|
var dowwumStr = require("locale").dow(date);
|
||||||
|
dowwumStr = "thursday";
|
||||||
|
if (calWeek)
|
||||||
|
dowwumStr = (weekDay ? dowwumStr.substr(0,Math.min(dowwumStr.length,6)) + (dowwumStr.length>=6 ? "." : "") : "week ") + "#" + ISO8601calWeek(date);
|
||||||
if (upperCase)
|
if (upperCase)
|
||||||
dowStr = dowStr.toUpperCase();
|
dowwumStr = dowwumStr.toUpperCase();
|
||||||
g.drawString(dowStr, x, y + (vectorFont ? 26 : 16));
|
g.drawString(dowwumStr, x, y + (vectorFont ? 26 : 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Show Weeknumber": {
|
||||||
|
value: (settings.weekNum !== undefined ? settings.weekNum : true),
|
||||||
|
format: v => v ? "On" : "Off",
|
||||||
|
onchange: v => {
|
||||||
|
settings.weekNum = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
"Uppercase": {
|
"Uppercase": {
|
||||||
value: (settings.upperCase !== undefined ? settings.upperCase : false),
|
value: (settings.upperCase !== undefined ? settings.upperCase : false),
|
||||||
format: v => v ? "On" : "Off",
|
format: v => v ? "On" : "Off",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue