Bugfix: Use gettimeofday instead of time. It provides higher precision.

Otherwise, we sometimes have a wrong date/time.
This commit is contained in:
Michael Stapelberg 2011-07-21 22:46:35 +02:00
parent 5e276db583
commit 53bf8bcb01

View File

@ -344,7 +344,9 @@ int main(int argc, char *argv[]) {
struct tm tm; struct tm tm;
while (1) { 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; struct tm *current_tm = NULL;
if (current_time != (time_t) -1) { if (current_time != (time_t) -1) {
localtime_r(&current_time, &tm); localtime_r(&current_time, &tm);