From ec00d63b59ba74aa463f5a0b2e7a36d434d1b386 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 22 Aug 2013 12:14:27 +0200 Subject: [PATCH] better check if reboot is to be scheduled on the next day --- hmland.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) 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) -- 2.39.2