Merge pull request #1728 from storm64/master

[Sched] Correct decodeTime(t) rounding
master
Gordon Williams 2022-04-25 11:47:56 +01:00 committed by GitHub
commit 29e3516fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -4,3 +4,4 @@
0.04: Fix `getTimeToAlarm` to check for next dow if alarm.t lower currentTime.
0.05: Export new functions (`newDefaultAlarm/Timer`), add Settings page
0.06: Refactor some methods to library
0.07: Correct `decodeTime(t)` to return a more likely expected time

View File

@ -110,9 +110,9 @@ exports.setSettings = function(settings) {
// time in ms -> { hrs, mins }
exports.decodeTime = function(t) {
t = 0 | t; // sanitise
let hrs = 0 | (t / 3600000);
return { hrs: hrs, mins: Math.round((t - hrs * 3600000) / 60000) };
t = Math.ceil(t / 60000); // sanitise to full minutes
let hrs = 0 | (t / 60);
return { hrs: hrs, mins: t - hrs * 60 };
}
// time in { hrs, mins } -> ms

View File

@ -1,7 +1,7 @@
{
"id": "sched",
"name": "Scheduler",
"version": "0.06",
"version": "0.07",
"description": "Scheduling library for alarms and timers",
"icon": "app.png",
"type": "scheduler",