From: Michael Gernoth Date: Thu, 22 Aug 2013 10:14:27 +0000 (+0200) Subject: better check if reboot is to be scheduled on the next day X-Git-Tag: v0.100~49 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/commitdiff_plain/ec00d63b59ba74aa463f5a0b2e7a36d434d1b386?hp=30a2aa7a896f165e42c76315ae523f4225f7b130 better check if reboot is to be scheduled on the next day --- diff --git a/hmland.c b/hmland.c index 5523cbd..e55eded 100644 --- a/hmland.c +++ b/hmland.c @@ -465,25 +465,15 @@ static int comm(int fd_in, int fd_out, int master_socket, int flags) return 0; } - if ((tm_s->tm_hour > reboot_at_hour) || - ((tm_s->tm_hour == reboot_at_hour) && (tm_s->tm_min >= reboot_at_minute))) { - if (verbose) - printf("Rebooting tomorrow at %02u:%02u\n", reboot_at_hour, reboot_at_minute); - - tm = 86400; - } else { - if (verbose) - printf("Rebooting today at %02u:%02u\n", reboot_at_hour, reboot_at_minute); - - tm = 0; - } - tm_s->tm_hour = reboot_at_hour; tm_s->tm_min = reboot_at_minute; tm_s->tm_sec = 0; - tm += mktime(tm_s); + tm = mktime(tm_s); reboot_seconds = tm - dev->opened_at; + + while (reboot_seconds <= 0) + reboot_seconds += 86400; } if (verbose && reboot_seconds)