summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiv Sardi <xaiki@iruya.(none)>2006-12-24 02:16:23 +0100
committerNiv Sardi <xaiki@iruya.(none)>2006-12-24 02:16:23 +0100
commitb3ed66d3f8abb4f2e1a2fb3bb53fbedd89bbd8d6 (patch)
treee8745807133ce8c3ef166318cc298cdbb1762e4c
parent755b158250b1e0cc3af9a9e10dc469ddd3099eca (diff)
microtime
-rwxr-xr-xvon-waitbin20505 -> 20737 bytes
-rw-r--r--von-wait.c15
2 files changed, 10 insertions, 5 deletions
diff --git a/von-wait b/von-wait
index df10d7a..5314222 100755
--- a/von-wait
+++ b/von-wait
Binary files 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 <gtk/gtk.h>
#include <cairo.h>
#include <time.h>
+#include <sys/time.h>
#include <stdlib.h>
#include <glib/gprintf.h>
@@ -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 ();