From 59f358fd0fd66be301b5c88c9458b02445f5ba30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Fri, 13 Jan 2017 16:52:58 -0500 Subject: [PATCH] set time structure at the right moment the way this was working before, we would populate the ttyclock->lt field *after* fetching the ttyclock->tm structure, which means that would get the `localtime` of the *previous* iteration. this created a one second delay in the clock display that was, I believe, unintentional. this accounts for part of the 2s delay when compared to other clocks like vtclock or xclock. Closes: #40 --- ttyclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index d140c3f..a9ef580 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -182,11 +182,11 @@ update_hour(void) int ihour; char tmpstr[128]; + ttyclock->lt = time(NULL); ttyclock->tm = localtime(&(ttyclock->lt)); if(ttyclock->option.utc) { ttyclock->tm = gmtime(&(ttyclock->lt)); } - ttyclock->lt = time(NULL); ihour = ttyclock->tm->tm_hour;