aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-14 06:43:15 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-14 06:43:15 +0200
commit880a8ef080e812614a55a80fb882291e8f072f9b (patch)
tree3500fe0d374caf0fec9a452b7cca8b880bb70188 /degesch.c
parent6f966d4aeebd07d5118a62102a2bc5b878903a9e (diff)
downloadxK-880a8ef080e812614a55a80fb882291e8f072f9b.tar.gz
xK-880a8ef080e812614a55a80fb882291e8f072f9b.tar.xz
xK-880a8ef080e812614a55a80fb882291e8f072f9b.zip
degesch: finally fix rearm_date_change_timer()
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/degesch.c b/degesch.c
index 929e43c..5b2177d 100644
--- a/degesch.c
+++ b/degesch.c
@@ -9111,10 +9111,18 @@ on_flush_timer (struct app_context *ctx)
static void
rearm_date_change_timer (struct app_context *ctx)
{
- const time_t seconds_per_day = 60 * 60 * 12;
+ struct tm tm_;
const time_t now = time (NULL);
- const time_t midnight = (now + seconds_per_day - 1)
- / seconds_per_day * seconds_per_day;
+ if (!soft_assert (localtime_r (&now, &tm_)))
+ return;
+
+ tm_.tm_sec = tm_.tm_min = tm_.tm_hour = 0;
+ tm_.tm_mday++;
+ tm_.tm_isdst = -1;
+
+ const time_t midnight = mktime (&tm_);
+ if (!soft_assert (midnight != (time_t) -1))
+ return;
poller_timer_set (&ctx->date_chg_tmr, (midnight - now) * 1000);
}