diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-10-01 22:21:56 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-10-01 22:21:56 +0200 |
commit | 56daba869ea917aa428a5911d5e49733bbda907c (patch) | |
tree | 1a62ab343418691ee660201a9955d023b0af2a03 | |
parent | 50567b0f64282e587ff589811ac1499f004d62f6 (diff) | |
download | weechat-56daba869ea917aa428a5911d5e49733bbda907c.zip |
core: replace call to gmtime by gmtime_r
-rw-r--r-- | src/core/hook/wee-hook-timer.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/core/hook/wee-hook-timer.c b/src/core/hook/wee-hook-timer.c index 880b99bad..dcaf830b3 100644 --- a/src/core/hook/wee-hook-timer.c +++ b/src/core/hook/wee-hook-timer.c @@ -45,24 +45,24 @@ void hook_timer_init (struct t_hook *hook) { time_t time_now; - struct tm *local_time, *gm_time; + struct tm *local_time, gm_time; int local_hour, gm_hour, diff_hour; gettimeofday (&HOOK_TIMER(hook, 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 ((local_time->tm_year > gm_time->tm_year) - || (local_time->tm_mon > gm_time->tm_mon) - || (local_time->tm_mday > gm_time->tm_mday)) + gmtime_r (&time_now, &gm_time); + gm_hour = gm_time.tm_hour; + if ((local_time->tm_year > gm_time.tm_year) + || (local_time->tm_mon > gm_time.tm_mon) + || (local_time->tm_mday > gm_time.tm_mday)) { diff_hour = (24 - gm_hour) + local_hour; } - else if ((gm_time->tm_year > local_time->tm_year) - || (gm_time->tm_mon > local_time->tm_mon) - || (gm_time->tm_mday > local_time->tm_mday)) + else if ((gm_time.tm_year > local_time->tm_year) + || (gm_time.tm_mon > local_time->tm_mon) + || (gm_time.tm_mday > local_time->tm_mday)) { diff_hour = (-1) * ((24 - local_hour) + gm_hour); } |