]> git.sur5r.net Git - i3/i3status/commitdiff
Bugfix: Use gettimeofday instead of time. It provides higher precision.
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 21 Jul 2011 20:46:35 +0000 (22:46 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 21 Jul 2011 20:46:35 +0000 (22:46 +0200)
Otherwise, we sometimes have a wrong date/time.

i3status.c

index 08ed940158c5bd2727131f176ee02469da9993e3..97e081b7445b91fe6018b7e4525006e39923b49a 100644 (file)
@@ -344,7 +344,9 @@ int main(int argc, char *argv[]) {
 
         struct tm tm;
         while (1) {
-                time_t current_time = time(NULL);
+                struct timeval tv;
+                gettimeofday(&tv, NULL);
+                time_t current_time = tv.tv_sec;
                 struct tm *current_tm = NULL;
                 if (current_time != (time_t) -1) {
                         localtime_r(&current_time, &tm);