From c5f27550f1f4380b82b48d41910dfe1543170858 Mon Sep 17 00:00:00 2001 From: lu713691 Date: Sun, 17 Jul 2022 21:48:17 +0100 Subject: [PATCH 1/2] Matrix Clock: Adding 24 hour clock as an available time format (controlled from the setting window --- apps/matrixclock/matrixclock.js | 17 +++++++++++++++-- apps/matrixclock/matrixclock.settings.js | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/matrixclock/matrixclock.js b/apps/matrixclock/matrixclock.js index 5477f64fb..c7f63dfdc 100644 --- a/apps/matrixclock/matrixclock.js +++ b/apps/matrixclock/matrixclock.js @@ -10,9 +10,16 @@ const Locale = require('locale'); const PREFERENCE_FILE = "matrixclock.settings.json"; -const settings = Object.assign({color: "theme", intensity: 'light'}, +const settings = Object.assign({color: "theme", time_format: '12 hour', intensity: 'light'}, require('Storage').readJSON(PREFERENCE_FILE, true) || {}); +var format_time; +if(settings.time_format == '24 hour'){ + format_time = (t) => format_time_24_hour(t); +} else { + format_time = (t) => format_time_12_hour(t); +} + const colors = { 'gray' :[0.5,0.5,0.5], 'green': [0,1.0,0], @@ -247,8 +254,14 @@ function format_date(now){ return Locale.dow(now,1) + " " + format00(now.getDate()); } +function format_time_24_hour(now){ + var time = new Date(now.getTime()); + var hours = time.getHours() ; -function format_time(now){ + return format00(hours) + ":" + format00(time.getMinutes()); +} + +function format_time_12_hour(now){ var time = new Date(now.getTime()); var hours = time.getHours() % 12; if(hours < 1){ diff --git a/apps/matrixclock/matrixclock.settings.js b/apps/matrixclock/matrixclock.settings.js index 0f625df4d..1f22a045f 100644 --- a/apps/matrixclock/matrixclock.settings.js +++ b/apps/matrixclock/matrixclock.settings.js @@ -1,6 +1,6 @@ (function(back) { const PREFERENCE_FILE = "matrixclock.settings.json"; - var settings = Object.assign({color : "theme", intensity: "light"}, + var settings = Object.assign({color : "theme", time_format: '12 hour', intensity: "light"}, require('Storage').readJSON(PREFERENCE_FILE, true) || {}); console.log("loaded:" + JSON.stringify(settings)); @@ -44,6 +44,7 @@ 'white on red', 'white on blue' ]), + "Time Format": stringInSettings("time_format", ['12 hour','24 hour']), "Intensity": stringInSettings("intensity", ['light', 'medium', 'high']) From e6586c02379b10724e853f2700ae47b0af034a84 Mon Sep 17 00:00:00 2001 From: lu713691 Date: Sun, 17 Jul 2022 21:57:20 +0100 Subject: [PATCH 2/2] Matrix Clock: Updating version no and change log --- apps/matrixclock/ChangeLog | 1 + apps/matrixclock/README.md | 9 +++++---- apps/matrixclock/metadata.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/matrixclock/ChangeLog b/apps/matrixclock/ChangeLog index 5d88618bd..ed59e37b0 100644 --- a/apps/matrixclock/ChangeLog +++ b/apps/matrixclock/ChangeLog @@ -3,3 +3,4 @@ 0.03: Keep the date from being overwritten, use correct colour from theme for clearing 0.04: Removed "wake LCD on face-up"-feature: A watch-face should not set things like "wake LCD on face-up". 0.05: Added support to other color themes (other then black) +0.06: Added support for 24 hour clock enabled from settings diff --git a/apps/matrixclock/README.md b/apps/matrixclock/README.md index a2add957a..01aef6544 100644 --- a/apps/matrixclock/README.md +++ b/apps/matrixclock/README.md @@ -5,10 +5,11 @@ ## Settings Please use the setting->App->Matrix Clock Menu to change the settings -| Setting | Description | -|-----------|--------------------------------------------------------------------------------------------------------------------| -| Color | by default set to **'theme'** to follow the theme colors. Selector also offers a selection of other colour schemes | -| Intensity | Changes the number of matrix streams that are falling | +| Setting | Description | +|-------------|--------------------------------------------------------------------------------------------------------------------| +| Color | By default set to **'theme'** to follow the theme colors. Selector also offers a selection of other colour schemes | +| Time Format | Choose between 12 hour and 24 hour time format | +| Intensity | Changes the number of matrix streams that are falling | ## Colour Themes diff --git a/apps/matrixclock/metadata.json b/apps/matrixclock/metadata.json index 1312210dd..eeefb6de4 100644 --- a/apps/matrixclock/metadata.json +++ b/apps/matrixclock/metadata.json @@ -1,7 +1,7 @@ { "id": "matrixclock", "name": "Matrix Clock", - "version": "0.05", + "version": "0.06", "description": "inspired by The Matrix, a clock of the same style", "icon": "matrixclock.png", "screenshots": [{"url":"matrix_green_on_black.jpg"}],