Add Midnight

Add README
pull/3560/head
Martin Pool 2024-09-04 01:10:59 +02:00
parent 42947f27bc
commit 2f91496e57
3 changed files with 37 additions and 18 deletions

18
apps/dutchclock/README.md Normal file
View File

@ -0,0 +1,18 @@
# Dutch Clock
This clock shows the time, in words, the way a Dutch person would tell you what time it is. Useful when learning Dutch.
It was inspired by my wife, who sometimes insists I tell her exactly what time it says on the watch and not just an approximation.
## Options
- Three modes:
- exact time ("zeven voor half zes / twee voor tien")
- approximate time, rounded to the nearest 5-minute mark ("bijna vijf voor half zes / tegen tienen") (the default)
- hybrid mode, rounded when close to the quarter marks and exact otherwise ("zeven voor half zes / tegen tienen")
- Option to turn top widgets on/off (on by default)
- Option to show digital time at the bottom (off by default)
- Option to show the date at the bottom (on by default)
## Screenshots
![](screenshotbangle1-2.png)
![](screenshotbangle2.png)
![](screenshotbangle1.png)

View File

@ -7,8 +7,9 @@ const SCREEN_HEIGHT = g.getHeight();
const TOP_SPACING = 5;
const WIDGETS_HEIGHT = 20;
const DATETIME_SPACING_HEIGHT = 5;
const DATE_HEIGHT = 10;
const TIME_HEIGHT = 10;
const DATE_HEIGHT = 10;
const BOTTOM_SPACING = 5;
const TEXT_WIDTH = SCREEN_WIDTH - 2;
@ -84,18 +85,19 @@ function draw() {
// Reset the state of the graphics library
g.clear(true);
// draw the current time (4x size 7 segment)
setFont(timeLines);
g.setFontAlign(0,0); // align center top
g.drawString(timeLines.join("\n"), X, Y, true /*clear background*/);
g.drawString(timeLines.join("\n"), X, Y, false);
if (bottomLines.length) {
// draw the time and/or date, in a normal font
g.setFont("6x8");
g.setFontAlign(0,1); // align center bottom
// pad the date - this clears the background if the date were to change length
g.drawString(bottomLines.join('\n'), SCREEN_WIDTH/2, SCREEN_HEIGHT - 5, true /*clear background*/);
g.drawString(bottomLines.join('\n'), SCREEN_WIDTH/2, SCREEN_HEIGHT - BOTTOM_SPACING, false);
}
/* Show launcher when middle button pressed
@ -130,7 +132,7 @@ function getBottomLines() {
}
if (settings.showDate) {
lines.push(locale.date(date, 1));
lines.push(locale.date(date));
}
return lines;
@ -153,6 +155,10 @@ function getBottomLines() {
}
function getExactTimeLines(m) {
if (m === 0) {
return ['middernacht'];
}
const hour = getHour(m);
const minutes = getMinutes(hour.offset);
@ -166,15 +172,8 @@ function getExactTimeLines(m) {
function getApproximateTimeLines(m) {
const roundMinutes = getRoundMinutes(m);
const hour = getHour(roundMinutes.minutes);
const minutes = getMinutes(hour.offset);
const lines = minutes.concat(hour.lines);
if (lines.length === 1) {
lines.push('uur');
}
const lines = getExactTimeLines(roundMinutes.minutes);
return addApproximateDescription(lines, roundMinutes.offset);
}
@ -222,7 +221,7 @@ function addApproximateDescription(lines, offset) {
return lines;
}
if (lines[1] === 'uur') {
if (lines.length === 1 || lines[1] === 'uur') {
const singular = lines[0];
const plural = getPlural(singular);
return {
@ -243,6 +242,7 @@ function addApproximateDescription(lines, offset) {
function getPlural(h) {
return {
middernacht: 'middernacht',
een: 'enen',
twee: 'tweeën',
drie: 'drieën',

View File

@ -3,16 +3,16 @@
"name": "Dutch Clock",
"shortName":"Dutch Clock",
"icon": "app.png",
"version":"0.10",
"version":"0.11",
"description": "A clock that displays the time the way a Dutch person would respond when asked what time it is.",
"type": "clock",
"tags": "clock,dutch,text",
"supports": ["BANGLEJS", "BANGLEJS2"],
"allow_emulator": true,
"screenshots": [
{"url":"screenshotbangle1-2.png"},
{"url":"screenshotbangle2.png"},
{"url":"screenshotbangle1.png"},
{"url":"screenshotbangle1-2.png"}
{"url":"screenshotbangle1.png"}
],
"storage": [
{"name":"dutchclock.app.js","url":"app.js"},
@ -22,6 +22,7 @@
],
"data": [
{"name":"dutchclock.json"}
]
],
"readme":"README.md"
}