From d6e189945e6467e87cb4e0d53bf1227bc793a5d2 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 2 Aug 2024 13:11:12 +0200 Subject: [PATCH 1/3] fix(measuretime): make sure to draw correct time number on overlapping-day hours --- apps/measuretime/measuretime.app.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/measuretime/measuretime.app.js b/apps/measuretime/measuretime.app.js index 97b56c710..49f5f2835 100644 --- a/apps/measuretime/measuretime.app.js +++ b/apps/measuretime/measuretime.app.js @@ -78,6 +78,19 @@ return lineEndFull - 5; }; + let drawHourString = function(hour, yLines) { + var hourForDrawing = 0; + if (hour < 0) { + // a negative hour => (+ and - = -) + hourForDrawing = 24 + hour; + } else if (hour >= 24) { + hourForDrawing = hour - 24; + } else { + hourForDrawing = hour; + } + g.drawString(hourForDrawing, hourStringXOffset(hourForDrawing), yLines, true); + }; + let drawTime = function () { g.clear(); var d = new Date(); @@ -101,12 +114,12 @@ switch (yTopLines - 88 + mins) { case -60: lineEnd = lineEndFull; - g.drawString(d.getHours()-1, hourStringXOffset(d.getHours()-1), yTopLines, true); + drawHourString(d.getHours() - 1, yTopLines); break; case 0: case 60: lineEnd = lineEndFull; - g.drawString(d.getHours(), hourStringXOffset(d.getHours()), yTopLines, true); + drawHourString(d.getHours(), yTopLines); break; case 45: case -45: @@ -136,11 +149,11 @@ case 0: case 60: lineEnd = lineEndFull; - g.drawString(d.getHours() + 1, hourStringXOffset(d.getHours()+1), yBottomLines, true); + drawHourString(d.getHours() + 1, yBottomLines);; break; case 120: lineEnd = lineEndFull; - g.drawString(d.getHours() + 2, hourStringXOffset(d.getHours()+2), yBottomLines, true); + drawHourString(d.getHours() + 2, yBottomLines); break; case 15: case 75: From 2b751ede2ffad170d71c6af2666d1b73ab22c4b1 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 2 Aug 2024 13:15:55 +0200 Subject: [PATCH 2/3] fix(measuretime): remove double semicolon --- apps/measuretime/measuretime.app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/measuretime/measuretime.app.js b/apps/measuretime/measuretime.app.js index 49f5f2835..419916416 100644 --- a/apps/measuretime/measuretime.app.js +++ b/apps/measuretime/measuretime.app.js @@ -149,7 +149,7 @@ case 0: case 60: lineEnd = lineEndFull; - drawHourString(d.getHours() + 1, yBottomLines);; + drawHourString(d.getHours() + 1, yBottomLines); break; case 120: lineEnd = lineEndFull; From 5bb2dc87a8e2d728e994bb3cb42a86f81bf6c47d Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 2 Aug 2024 16:02:08 +0200 Subject: [PATCH 3/3] fix(measuretime): update changelog and metadata file --- apps/measuretime/ChangeLog | 1 + apps/measuretime/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/measuretime/ChangeLog b/apps/measuretime/ChangeLog index d0ac21aac..886e92f22 100644 --- a/apps/measuretime/ChangeLog +++ b/apps/measuretime/ChangeLog @@ -1,2 +1,3 @@ 0.1: Initial release 0.2: Draw line for 3d effect, fix number alignment +0.3: Fix day-end overflowing hour calculation diff --git a/apps/measuretime/metadata.json b/apps/measuretime/metadata.json index 6ba022dc0..e25fe1ef6 100644 --- a/apps/measuretime/metadata.json +++ b/apps/measuretime/metadata.json @@ -1,7 +1,7 @@ { "id": "measuretime", "name": "Measure Time", - "version": "0.2", + "version": "0.3", "description": "Measure Time in a fancy way.", "icon": "measuretime_icon.png", "screenshots": [