--- programs/xclock/Clock.c.orig	Fri Feb 25 21:45:15 2000
+++ programs/xclock/Clock.c	Fri Jun  2 19:11:06 2000
@@ -45,6 +45,7 @@
 /* $XFree86: xc/programs/xclock/Clock.c,v 3.8 2000/11/02 02:51:24 dawes Exp $ */
 
 #include <X11/Xlib.h>
+#include <X11/Xatom.h>
 #include <X11/StringDefs.h>
 #include <X11/IntrinsicP.h>
 #include "ClockP.h"
@@ -116,6 +117,10 @@
         offset(analog), XtRImmediate, (XtPointer) TRUE},
     {XtNbrief, XtCBoolean, XtRBoolean, sizeof(Boolean),
         offset(brief), XtRImmediate, (XtPointer) FALSE},
+    {XtNinTitle, XtCBoolean, XtRBoolean, sizeof(Boolean),
+        offset(intitle), XtRImmediate, (XtPointer) FALSE },
+    {XtNformat, XtCString, XtRString, sizeof (char *),
+        offset(format), XtRString, NULL },
     {XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean),
 	offset(chime), XtRImmediate, (XtPointer) FALSE },
     {XtNpadding, XtCMargin, XtRInt, sizeof(int),
@@ -210,26 +215,6 @@
 		    NULL, 0 );
 }
 
-static char *
-TimeString (ClockWidget w, struct tm *tm)
-{
-   if (w->clock.brief)
-   {
-      static char brief[5];
-      sprintf (brief, "%02d:%02d", tm->tm_hour, tm->tm_min);
-      return brief;
-   }
-   else if (w->clock.utime)
-   {
-      static char utime[35];
-      Time_t tsec;
-      tsec = time(NULL);
-      sprintf (utime, "%10lu seconds since Epoch", (unsigned long)tsec);
-      return utime;
-   }
-   return asctime (tm);
-}
-
 /* ARGSUSED */
 static void 
 Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
@@ -250,10 +235,23 @@
        char *str;
        struct tm tm;
        Time_t time_value;
+       char buf[ASCII_TIME_BUFLEN];
 
        (void) time(&time_value);
        tm = *localtime(&time_value);
-       str = TimeString (w, &tm);
+       if (w->clock.brief)
+          w->clock.format = "%R";
+       else if (w->clock.utime)
+	  w->clock.format = "%s seconds since Epoch";
+       if (w->clock.format != NULL) {
+	  if (strftime(buf, ASCII_TIME_BUFLEN,
+		       w->clock.format, &tm) == 0)
+	     str = "FORMAT TOO LONG";
+	  else
+	     str = buf;
+       } else {
+	  str = asctime(&tm);
+       }
        if (w->clock.font == NULL)
           w->clock.font = XQueryFont( XtDisplay(w),
 				      XGContextFromGC(
@@ -359,6 +357,7 @@
         DrawClockFace(w);
     } else {
 	w->clock.prev_time_string[0] = '\0';
+	w->clock.prev_time_len = 0;
     }
     clock_tic((XtPointer)w, (XtIntervalId)0);
 }
@@ -371,7 +370,8 @@
 	struct tm tm; 
 	Time_t	time_value;
 	struct timeval	tv;
-	char	*time_ptr;
+	char	*time_ptr= "";
+	size_t	time_len = 0, time_skip = 0;
         register Display *dpy = XtDisplay(w);
         register Window win = XtWindow(w);
 
@@ -407,27 +407,52 @@
 #endif
 	    }
 	}
+	if( w->clock.analog == FALSE || w->clock.intitle == TRUE ) {
+	    int prev_time_len;
+	    char *p, *q;
+	    int i;
+	    char buf[ASCII_TIME_BUFLEN];
+
+	    if( w->clock.format != NULL ) {
+		p = buf;
+		time_len = strftime(buf, ASCII_TIME_BUFLEN,
+					w->clock.format, &tm);	
+		if (time_len == 0) {
+		    p = "FORMAT TOO LONG";
+		    time_len = strlen(p);
+		}
+	    } else {
+		p = asctime(&tm);
+		time_len = strlen(p);
+	    }
+	    if (p[time_len - 1] == '\n')
+		p[--time_len] = '\0';
+	    prev_time_len = w->clock.prev_time_len;
+	    w->clock.prev_time_len = time_len;
+	    q = w->clock.prev_time_string;
+	    for (i = 0; i < time_len &&
+			i < prev_time_len && 
+	    		p[i] == q[i]; i++);
+	    strcpy (q+i, p+i);
+	    time_skip = i;
+	    time_ptr = q;
+	}
+	if( w->clock.intitle == TRUE ) {
+	    XStoreName(XtDisplay((Widget)w), XtWindow((Widget)w), time_ptr);
+	    XSetIconName(XtDisplay((Widget)w), XtWindow((Widget)w), time_ptr);
+	}
 	if( w->clock.analog == FALSE ) {
 	    int	clear_from;
-	    int i, len, prev_len;
-
-	    time_ptr = TimeString (w, &tm);
-	    len = strlen (time_ptr);
-	    if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0';
-	    prev_len = strlen (w->clock.prev_time_string);
-	    for (i = 0; ((i < len) && (i < prev_len) && 
-	    		 (w->clock.prev_time_string[i] == time_ptr[i])); i++);
-	    strcpy (w->clock.prev_time_string+i, time_ptr+i);
 
 	    XDrawImageString (dpy, win, w->clock.myGC,
-			      (1+w->clock.padding +
-			       XTextWidth (w->clock.font, time_ptr, i)),
-			      w->clock.font->ascent+w->clock.padding,
-			      time_ptr + i, len - i);
+			      (2+w->clock.padding +
+			       XTextWidth (w->clock.font, time_ptr, time_skip)),
+			      (w->core.height + w->clock.font->ascent) / 2,
+			      time_ptr + time_skip, time_len - time_skip);
 	    /*
 	     * Clear any left over bits
 	     */
-	    clear_from = XTextWidth (w->clock.font, time_ptr, len)
+	    clear_from = XTextWidth (w->clock.font, time_ptr, time_len)
  	    		+ 2 + w->clock.padding;
 	    if (clear_from < (int)w->core.width)
 		XFillRectangle (dpy, win, w->clock.EraseGC,
--- programs/xclock/Clock.h.orig	Fri Jan 21 10:55:29 2000
+++ programs/xclock/Clock.h	Fri Jun  2 11:38:12 2000
@@ -63,6 +63,8 @@
  Name		     Class		RepType		Default Value
  ----		     -----		-------		-------------
  analog		     Boolean		Boolean		True
+ inTitle	     Boolean		Boolean		False
+ format		     String		char *		NULL
  background	     Background		Pixel		white
  backingStore	     BackingStore	BackingStore	default
  border		     BorderColor	Pixel		Black
@@ -91,6 +93,12 @@
 
 		/* Boolean: digital if FALSE */
 #define XtNanalog "analog"
+
+		/* Boolean: normal title if FALSE */
+#define XtNinTitle "inTitle"
+
+		/* strftime format string */
+#define XtNformat "format"
 
 		/* Boolean: only hour/minute if TRUE */
 #define XtNbrief  "brief"
--- programs/xclock/ClockP.h.orig	Fri Jan 21 10:55:29 2000
+++ programs/xclock/ClockP.h	Fri Jun  2 11:38:12 2000
@@ -55,7 +55,7 @@
 #include <X11/Xaw/SimpleP.h>
 
 #define SEG_BUFF_SIZE		128
-#define ASCII_TIME_BUFLEN	32	/* big enough for 26 plus slop */
+#define ASCII_TIME_BUFLEN	256	/* big enough for user's formatted time */
 
 /* New fields for the clock widget instance record */
 typedef struct {
@@ -76,6 +76,8 @@
 	 Boolean analog;
 	 Boolean brief;
 	 Boolean show_second_hand;
+	 Boolean intitle;	/* show digital time in the title */
+	 char	*format;	/* digital clock format */
 	 Dimension second_hand_length;
 	 Dimension minute_hand_length;
 	 Dimension hour_hand_length;
@@ -91,6 +93,7 @@
 	 struct tm  otm ;
 	 XtIntervalId interval_id;
 	 char prev_time_string[ASCII_TIME_BUFLEN];
+	 int  prev_time_len;
    } ClockPart;
 
 /* Full instance record declaration */
--- programs/xclock/xclock.c.orig	Mon Nov  6 23:05:41 2000
+++ programs/xclock/xclock.c	Thu Feb  1 19:57:44 2001
@@ -54,11 +54,13 @@
 {"-highlight",	"*clock.highlight",	XrmoptionSepArg,	NULL},
 {"-update",	"*clock.update",	XrmoptionSepArg,	NULL},
 {"-padding",	"*clock.padding",	XrmoptionSepArg,	NULL},
+{"-intitle",	"*clock.inTitle",	XrmoptionNoArg,		"TRUE"},
 {"-d",		"*clock.analog",	XrmoptionNoArg,		"FALSE"},
 {"-digital",	"*clock.analog",	XrmoptionNoArg,		"FALSE"},
 {"-analog",	"*clock.analog",	XrmoptionNoArg,		"TRUE"},
 {"-brief",      "*clock.brief",	        XrmoptionNoArg,	        "TRUE"},
 {"-utime",      "*clock.utime",	        XrmoptionNoArg,	        "TRUE"},
+{"-format",	"*clock.format",	XrmoptionSepArg,	NULL},
 };
 
 static void quit ( Widget w, XEvent *event, String *params, 

