Merge pull request #2119 from peerdavid/master

[BW Clock] Show calendar week
pull/2120/head
Gordon Williams 2022-09-08 15:39:47 +01:00 committed by GitHub
commit 3bcfa8c036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -18,3 +18,4 @@
0.18: Set timer for an agenda entry by simply clicking in the middle of the screen. Only one timer can be set.
0.19: Fix - Compatibility with "Digital clock widget"
0.20: Better handling of async data such as getPressure.
0.21: On the default menu the week of year can be shown.

View File

@ -198,6 +198,7 @@ function imgMountain() {
var menu = [
[
function(){ return [ null, null ] },
function(){ return [ "Week " + weekOfYear(), null ] },
],
[
function(){ return [ "Bangle", imgWatch() ] },
@ -423,6 +424,19 @@ function getWeather(){
};
}
// From https://weeknumber.com/how-to/javascript
function weekOfYear() {
var date = new Date();
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
function isAlarmEnabled(idx){
try{
@ -600,7 +614,7 @@ function drawTime(){
}
var imgWidth = 0;
if(menuImg !== undefined){
if(menuImg){
imgWidth = 24.0;
var strWidth = g.stringWidth(menuText);
var scale = imgWidth / menuImg.width;

View File

@ -1,7 +1,7 @@
{
"id": "bwclk",
"name": "BW Clock",
"version": "0.20",
"version": "0.21",
"description": "A very minimalistic clock to mainly show date and time.",
"readme": "README.md",
"icon": "app.png",