]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/tclock.c
ncurses 6.5 - patch 20240504
[ncurses.git] / test / tclock.c
index 75b6570f4a032b80211c1bc16f864036a3afd7b2..1a749628914dd82492aa7bf95816379cc58233f6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: tclock.c,v 1.47 2022/12/10 23:23:27 tom Exp $ */
+/* $Id: tclock.c,v 1.48 2023/02/25 16:42:22 tom Exp $ */
 
 #define NEED_TIME_H
 #include <test.priv.h>
@@ -133,6 +133,8 @@ VERSION_COMMON()
 int
 main(int argc, char *argv[])
 {
+    static TimeType initial;
+
     int i, cx, cy;
     double cr, mradius, hradius, mangle, hangle;
     double sangle, sradius, hours;
@@ -147,10 +149,7 @@ main(int argc, char *argv[])
     char szChar[20];
     char *text;
     short my_bg = COLOR_BLACK;
-#if HAVE_GETTIMEOFDAY
-    struct timeval current;
-#endif
-    double fraction = 0.0;
+    TimeType current;
 #if HAVE_USE_DEFAULT_COLORS
     bool d_option = FALSE;
 #endif
@@ -236,11 +235,9 @@ main(int argc, char *argv[])
        hdx = A2X(hangle, hradius);
        hdy = A2Y(hangle, hradius);
 
-#if HAVE_GETTIMEOFDAY
-       gettimeofday(&current, 0);
-       fraction = ((double) current.tv_usec / 1.0e6);
-#endif
-       sangle = ((t->tm_sec + fraction) * (2.0 * PI) / 60.0);
+       GetClockTime(&current);
+
+       sangle = (ElapsedSeconds(&initial, &current) * (2.0 * PI) / 60.0);
        sdx = A2X(sangle, sradius);
        sdy = A2Y(sangle, sradius);