mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-27 05:51:55 +00:00
FIX time check #79
This commit is contained in:
parent
7ec7a88e98
commit
ef662584a9
1 changed files with 10 additions and 12 deletions
|
|
@ -216,20 +216,18 @@ function toggleDark(setDark) {
|
||||||
function checkDarkLightMode() {
|
function checkDarkLightMode() {
|
||||||
if (DribbblishShared.config.get("theme") != 2) return;
|
if (DribbblishShared.config.get("theme") != 2) return;
|
||||||
|
|
||||||
const start = new Date();
|
const start = 60 * parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[0])
|
||||||
start.setHours(DribbblishShared.config.get("darkModeOnTime").split(":")[0]);
|
+ parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[1])
|
||||||
start.setMinutes(DribbblishShared.config.get("darkModeOnTime").split(":")[1]);
|
const end = 60 * parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[0])
|
||||||
start.setSeconds(0);
|
+ parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[1])
|
||||||
|
|
||||||
const end = new Date();
|
const now = new Date()
|
||||||
end.setHours(DribbblishShared.config.get("darkModeOffTime").split(":")[0]);
|
const time = 60 * now.getHours() + now.getMinutes()
|
||||||
end.setMinutes(DribbblishShared.config.get("darkModeOffTime").split(":")[1]);
|
|
||||||
end.setSeconds(0);
|
|
||||||
if (end < start) end.setTime(end.getTime() + 24 * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
const now = new Date();
|
if (end < start)
|
||||||
|
dark = start <= time || time < end
|
||||||
const dark = start <= now && now < end;
|
else
|
||||||
|
dark = start <= time && time < end
|
||||||
toggleDark(dark);
|
toggleDark(dark);
|
||||||
}
|
}
|
||||||
// Run every Minute to check time and set dark / light mode
|
// Run every Minute to check time and set dark / light mode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue