1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

Fix timer hook when daylight saving time is enabled (problem with "day changed" message)

This commit is contained in:
Sebastien Helleu
2008-11-01 15:01:08 +01:00
parent b400448fc1
commit 20219ef1a3
+11 -5
View File
@@ -520,7 +520,9 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
{
struct t_hook *new_hook;
struct t_hook_timer *new_hook_timer;
struct timezone tz;
time_t time_now;
struct tm *local_time, *gm_time;
int local_hour, gm_hour;
if (interval <= 0)
return NULL;
@@ -541,9 +543,13 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
new_hook_timer->callback = callback;
new_hook_timer->interval = interval;
new_hook_timer->remaining_calls = max_calls;
tz.tz_minuteswest = 0;
gettimeofday (&new_hook_timer->last_exec, &tz);
gettimeofday (&new_hook_timer->last_exec, NULL);
time_now = time (NULL);
local_time = localtime(&time_now);
local_hour = local_time->tm_hour;
gm_time = gmtime(&time_now);
gm_hour = gm_time->tm_hour;
if ((interval >= 1000) && (align_second > 0))
{
@@ -553,7 +559,7 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
new_hook_timer->last_exec.tv_usec = 1000;
new_hook_timer->last_exec.tv_sec =
new_hook_timer->last_exec.tv_sec -
((new_hook_timer->last_exec.tv_sec - (tz.tz_minuteswest * 60)) %
((new_hook_timer->last_exec.tv_sec + ((local_hour - gm_hour) * 3600)) %
align_second);
}