Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Dec 1997 10:12:49 +0100
From:      Gianmarco Giovannelli <gmarco@giovannelli.it>
To:        questions@freebsd.org
Subject:   patch for xclock...
Message-ID:  <348E5D11.60877C9D@giovannelli.it>

next in thread | raw e-mail | index | archive | help
I have modified xclock to allow other digital time form of display...
If someone in interested, here are the patches...


##### begin ##########

--- Clock.c.orig        Mon Oct 23 15:54:50 1995
+++ Clock.c     Tue Dec  9 18:43:29 1997
@@ -91,6 +91,8 @@
 #define min(a, b) ((a) < (b) ? (a) : (b))
 #define abs(a) ((a) < 0 ? -(a) : (a))

+/* Choose your preferred format from the strftime manual */
+#define TIME_FORMAT    "%T"

 /* Initialization of defaults */

@@ -205,13 +207,13 @@

     min_width = min_height = ANALOG_SIZE_DEFAULT;
     if(!w->clock.analog) {
-       char *str;
+       char str[30];
        struct tm tm;
        Time_t time_value;

        (void) time(&time_value);
        tm = *localtime(&time_value);
-       str = asctime(&tm);
+       strftime(str, 29, TIME_FORMAT, &tm);
        if (w->clock.font == NULL)
           w->clock.font = XQueryFont( XtDisplay(w),
                                      XGContextFromGC(
@@ -333,7 +335,7 @@
         ClockWidget w = (ClockWidget)client_data;
        struct tm tm;
        Time_t  time_value;
-       char    *time_ptr;
+       char    time_ptr[30];
         register Display *dpy = XtDisplay(w);
         register Window win = XtWindow(w);

@@ -362,7 +364,7 @@
            int clear_from;
            int i, len, prev_len;

-           time_ptr = asctime(&tm);
+       strftime(time_ptr, 29, TIME_FORMAT, &tm);
            len = strlen (time_ptr);
            if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0';
            prev_len = strlen (w->clock.prev_time_string);


#### end ####


-- 

Regards...

Gianmarco
"Unix expert since yesterday"

http://www2.masternet.it



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?348E5D11.60877C9D>