fix: time from midnight

fix issue where time from midnight was wrong on days where DST changes
This commit is contained in:
cv
2021-10-31 22:04:19 +01:00
parent 418f8018fe
commit ad89a780be
+7 -4
View File
@@ -96,12 +96,15 @@ export class Timer {
// get current time in epoc
_getCurrentTime() {
// date today at midnight
const now = new Date();
const midnight = new Date(now).setHours(0, 0, 0);
// return diffence
return now - midnight;
// extract milliseconds since midnight
let elapsed = now.getHours() * 3600000;
elapsed += now.getMinutes() * 60000;
elapsed += now.getSeconds() * 1000;
elapsed += now.getMilliseconds();
return elapsed;
}
_getExpectedFinish() {