forked from FOSS/BangleApps
Nifty-A Clock with iso week number
* code changed to show iso week number * settings file created * screenshot updated * settings screenshot created * readme adjusted * and app.json increased to v0.02master
parent
6b829c7e71
commit
a6d87816bb
|
@ -4316,7 +4316,7 @@
|
||||||
{
|
{
|
||||||
"id": "ffcniftya",
|
"id": "ffcniftya",
|
||||||
"name": "Nifty-A Clock",
|
"name": "Nifty-A Clock",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "A nifty clock with time and date",
|
"description": "A nifty clock with time and date",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"screenshot_nifty.png"}],
|
"screenshots": [{"url":"screenshot_nifty.png"}],
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
0.01: New Clock Nifty A
|
0.01: New Clock Nifty A
|
||||||
|
0.02: Shows the current week number, can be disabled via settings ""
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
# Nifty-A Clock
|
# Nifty-A Clock
|
||||||
|
|
||||||
|
##This is the clock
|
||||||

|

|
||||||
|
|
||||||
|
##And the week number can be turned On/Off via settings
|
||||||
|

|
||||||
|
default is "On"
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,18 @@ const center = {
|
||||||
y: Math.round(((viewport.height - widget) / 2) + widget),
|
y: Math.round(((viewport.height - widget) / 2) + widget),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ISO8601_week_no(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 d02(value) {
|
function d02(value) {
|
||||||
return ('0' + value).substr(-2);
|
return ('0' + value).substr(-2);
|
||||||
}
|
}
|
||||||
|
@ -29,23 +41,26 @@ function draw() {
|
||||||
const minutes = d02(now.getMinutes());
|
const minutes = d02(now.getMinutes());
|
||||||
const day = d02(now.getDate());
|
const day = d02(now.getDate());
|
||||||
const month = d02(now.getMonth() + 1);
|
const month = d02(now.getMonth() + 1);
|
||||||
const year = now.getFullYear();
|
const year = now.getFullYear(now);
|
||||||
|
const weekNum = d02(ISO8601_week_no(now));
|
||||||
const month2 = locale.month(now, 3);
|
const monthName = locale.month(now, 3);
|
||||||
const day2 = locale.dow(now, 3);
|
const dayName = locale.dow(now, 3);
|
||||||
|
|
||||||
|
const centerTimeScaleX = center.x + 32 * scale;
|
||||||
g.setFontAlign(1, 0).setFont("Vector", 90 * scale);
|
g.setFontAlign(1, 0).setFont("Vector", 90 * scale);
|
||||||
g.drawString(hour, center.x + 32 * scale, center.y - 31 * scale);
|
g.drawString(hour, centerTimeScaleX, center.y - 31 * scale);
|
||||||
g.drawString(minutes, center.x + 32 * scale, center.y + 46 * scale);
|
g.drawString(minutes, centerTimeScaleX, center.y + 46 * scale);
|
||||||
|
|
||||||
g.fillRect(center.x + 30 * scale, center.y - 72 * scale, center.x + 32 * scale, center.y + 74 * scale);
|
g.fillRect(center.x + 30 * scale, center.y - 72 * scale, center.x + 32 * scale, center.y + 74 * scale);
|
||||||
|
|
||||||
|
const centerDatesScaleX = center.x + 40 * scale;
|
||||||
g.setFontAlign(-1, 0).setFont("Vector", 16 * scale);
|
g.setFontAlign(-1, 0).setFont("Vector", 16 * scale);
|
||||||
g.drawString(year, center.x + 40 * scale, center.y - 62 * scale);
|
g.drawString(year, centerDatesScaleX, center.y - 62 * scale);
|
||||||
g.drawString(month, center.x + 40 * scale, center.y - 44 * scale);
|
g.drawString(month, centerDatesScaleX, center.y - 44 * scale);
|
||||||
g.drawString(day, center.x + 40 * scale, center.y - 26 * scale);
|
g.drawString(day, centerDatesScaleX, center.y - 26 * scale);
|
||||||
g.drawString(month2, center.x + 40 * scale, center.y + 48 * scale);
|
g.drawString(weekNum, centerDatesScaleX, center.y + 15 * scale);
|
||||||
g.drawString(day2, center.x + 40 * scale, center.y + 66 * scale);
|
g.drawString(monthName, centerDatesScaleX, center.y + 48 * scale);
|
||||||
|
g.drawString(dayName, centerDatesScaleX, center.y + 66 * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
(function(back) {
|
||||||
|
var FILE = "\ffcniftya.json";
|
||||||
|
// Load settings
|
||||||
|
var cfg = Object.assign({
|
||||||
|
showWeekNum: true,
|
||||||
|
}, require('Storage').readJSON(FILE, true) || {});
|
||||||
|
|
||||||
|
function writeSettings() {
|
||||||
|
require('Storage').writeJSON(FILE, cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the menu
|
||||||
|
E.showMenu({
|
||||||
|
"" : { "title" : "Nifty-A Clock" },
|
||||||
|
"< Back" : () => back(),
|
||||||
|
'week number?': {
|
||||||
|
value: cfg.showWeekNum,
|
||||||
|
format: v => v?"On":"Off",
|
||||||
|
onchange: v => {
|
||||||
|
cfg.showWeekNum = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 51 KiB |
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
Loading…
Reference in New Issue