From b3ed66d3f8abb4f2e1a2fb3bb53fbedd89bbd8d6 Mon Sep 17 00:00:00 2001 From: Niv Sardi Date: Sun, 24 Dec 2006 02:16:23 +0100 Subject: microtime --- von-wait | Bin 20505 -> 20737 bytes von-wait.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/von-wait b/von-wait index df10d7a..5314222 100755 Binary files a/von-wait and b/von-wait differ diff --git a/von-wait.c b/von-wait.c index ba2ceab..23cf802 100644 --- a/von-wait.c +++ b/von-wait.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -13,7 +14,7 @@ struct private { time_t time; time_t von_arrives; - struct tm *tm; + struct timeval tv_now; }; static gboolean time_handler (GtkWidget* w) @@ -45,8 +46,10 @@ static void paint (GtkWidget *widget, GdkEventExpose *eev, struct private *p) { gint sec, min, hour, day; p->time = p->von_arrives - time(NULL); - p->tm = localtime (&p->time); - + gettimeofday(&p->tv_now, NULL); + + localtime (&p->tv_now.tv_sec); + day = p->time / (3600*24); p->time -= day*(3600*24); @@ -58,7 +61,9 @@ static void paint (GtkWidget *widget, GdkEventExpose *eev, struct private *p) { sec = p->time; - gc_time = g_strdup_printf("Von arrives in %02dd %02dh %02dm %02ds", day, hour, min, sec); + gc_time = g_strdup_printf("Von arrives in %02dd %02d:%02d:%02d:%02d", + day, hour, min, sec, + (int) ((p->tv_now.tv_usec)/10e3)); width = widget->allocation.width; height = widget->allocation.height; @@ -141,7 +146,7 @@ gint main (gint argc, gchar **argv) { gtk_widget_show_all (window); - gtk_timeout_add (SECOND_INTERVAL, (GtkFunction) time_handler, window); + gtk_timeout_add (SECOND_INTERVAL/100, (GtkFunction) time_handler, window); gtk_main (); -- cgit v1.2.3