summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--typing-break/drw-timer.c10
-rw-r--r--typing-break/drw-timer.h2
2 files changed, 5 insertions, 7 deletions
diff --git a/typing-break/drw-timer.c b/typing-break/drw-timer.c
index a757911e..fc7cc104 100644
--- a/typing-break/drw-timer.c
+++ b/typing-break/drw-timer.c
@@ -23,7 +23,7 @@
struct _DrwTimer
{
- GTimeVal start_time;
+ gint64 start_time;
};
DrwTimer * drw_timer_new (void)
@@ -35,14 +35,12 @@ DrwTimer * drw_timer_new (void)
void drw_timer_start (DrwTimer *timer)
{
- g_get_current_time (&timer->start_time);
+ timer->start_time = g_get_real_time ();
}
-double drw_timer_elapsed (DrwTimer *timer)
+gint drw_timer_elapsed (DrwTimer *timer)
{
- GTimeVal now;
- g_get_current_time (&now);
- return now.tv_sec - timer->start_time.tv_sec;
+ return (g_get_real_time () - timer->start_time) / G_USEC_PER_SEC;
}
void drw_timer_destroy (DrwTimer *timer)
diff --git a/typing-break/drw-timer.h b/typing-break/drw-timer.h
index 428d9480..a9ab2ea7 100644
--- a/typing-break/drw-timer.h
+++ b/typing-break/drw-timer.h
@@ -36,7 +36,7 @@
typedef struct _DrwTimer DrwTimer;
DrwTimer * drw_timer_new (void);
void drw_timer_start (DrwTimer *timer);
-double drw_timer_elapsed (DrwTimer *timer);
+gint drw_timer_elapsed (DrwTimer *timer);
void drw_timer_destroy (DrwTimer *timer);
#endif /* __DRW_TIMER_H__ */