Skip to content

Commit 092dd0c

Browse files
committed
schedclock: update app icon size; update github username; fix dup time alert
1 parent bbf50fa commit 092dd0c

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

apps/schedclock/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ You can also remove the extra `schedclock` alarms manually with the [Scheduler](
2929

3030
## Requests
3131

32-
Send requests to [thinkpoop](https://github.com/thinkpoop) on GitHub
32+
Send requests to [kidneyhex](https://github.com/kidneyhex) on GitHub.
33+
34+
Make whatever changes you'd like.
3335

3436
## Creator
3537

36-
[thinkpoop](https://github.com/thinkpoop)
38+
[kidneyhex](https://github.com/kidneyhex)
3739

3840
## Attribution
3941

apps/schedclock/app-icon.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/schedclock/lib.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ exports.onAlarm = function(index, clock) {
3232
const Sched = require("sched");
3333
const alarm = Sched.getAlarm(`${APP_ID}.${index}`);
3434
alarm.last = date.getDate(); // prevent second run on the same day
35-
// -- Don't think alarm.date is required, but just in case
36-
//date.setDate(alarm.last + 1);
37-
//alarm.date = date.toLocalISOString().slice(0,10);
3835
Sched.setAlarm(alarm.id, alarm);
3936
setClock(clock);
4037
};
@@ -56,24 +53,28 @@ exports.syncAlarms = function() {
5653
// If the app is disabled, we're done.
5754
if (!settings.enabled) return;
5855

59-
const time = new Date();
60-
const currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
61-
56+
// Alarms need "last" set to let sched know they've already ran for the day
57+
// So if an alarm is for before "now", set last to yesterday so it still triggers today
58+
// else set last to today.
59+
const currentDate = new Date();
60+
const currentTime = (currentDate.getHours()*3600000)+(currentDate.getMinutes()*60000)+(currentDate.getSeconds()*1000);
61+
const dayOfMonthToday = currentDate.getDate();
62+
const dayOfMonthYesterday = dayOfMonthToday - 1;
63+
6264
// Add a new alarm for each setting item
6365
settings.sched.forEach((item, index) => {
6466

65-
if (item.hour === undefined) return;
67+
// Skip invalid records
68+
if (item.hour === undefined || item.minute === undefined) return;
6669

67-
const schedTime = (item.hour * 3600000) + (item.minute * 60000);
68-
const today = time.getDate();
69-
const yesterday = today - 1;
70+
const scheduledTime = (item.hour * 3600000) + (item.minute * 60000);
7071

7172
// Create the new alarm object and save it using a unique ID.
7273
Sched.setAlarm(`${APP_ID}.${index}`, {
73-
t: schedTime, // time in milliseconds since midnight
74+
t: scheduledTime, // time in milliseconds since midnight
7475
on: true,
7576
rp: true,
76-
last: (schedTime > currentTime) ? yesterday : today,
77+
last: (scheduledTime > currentTime) ? dayOfMonthYesterday : dayOfMonthToday,
7778
dow: item.dow,
7879
hidden: true,
7980
appid: APP_ID,

apps/schedclock/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Schedule Clock Faces",
33
"shortName":"Schedule Clock",
44
"version":"0.01",
5-
"author": "thinkpoop",
5+
"author": "kidneyhex",
66
"description": "Change clock faces on a schedule.",
77
"icon": "app.png",
88
"tags": "tool",

apps/schedclock/settings.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,9 @@
213213

214214
if (validationError) {
215215
E.showAlert(
216-
/*LANG*/"Time conflict",
217-
/*LANG*/"An entry for this time already exists."
216+
/*LANG*/"An entry for this time already exists.",
217+
/*LANG*/"Time conflict"
218218
).then(
219-
// Note: not sure if this is the best way to return to the menu
220219
()=>E.showMenu(menu)
221220
);
222221
return; // Prevent saving

0 commit comments

Comments
 (0)