Skip to content

Commit

Permalink
nightlight@Severga: Fix bug with state switch in auto mode (#6433)
Browse files Browse the repository at this point in the history
  • Loading branch information
Severga authored Sep 18, 2024
1 parent 3ed1675 commit 8e808be
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions nightlight@Severga/files/nightlight@Severga/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,16 @@ NightLightApplet.prototype = {
},

_check_time: function() {
let now = Date.now();
let start = new Date();
start.setHours(this.startH);
start.setMinutes(this.startM);
start.setSeconds(0);
let end;
if ((this.endH * 60 + this.endM) >= (this.startH * 60 + this.startM)) {
end = new Date();
let start = this.startH * 3600 + this.startM * 60;
let end = this.endH * 3600 + this.endM * 60;
let now = new Date(); now = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
let on = false;
if (start <= end) {
if (now >= start && now < end) on = true;
} else {
end = new Date (now + 86400000);
if ((now >= start && now < 86400) || (now >= 0 && now < end)) on = true;
}
end.setHours(this.endH);
end.setMinutes(this.endM);
end.setSeconds(0);
if (now >= start && now < end) {
if (on) {
this.autoAndOn = true;
this._turn_on();
} else {
Expand Down

0 comments on commit 8e808be

Please sign in to comment.