From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3222 invoked from network); 16 Jan 1998 14:25:50 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 16 Jan 1998 14:25:49 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id IAA20197; Fri, 16 Jan 1998 08:51:44 -0500 (EST) Resent-Date: Fri, 16 Jan 1998 08:51:44 -0500 (EST) From: pws@ibmth.difi.unipi.it Message-Id: <9801161314.AA38808@ibmth.difi.unipi.it> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: PATCH: zsh-3.1.2-zefram3: 12 hour clock in prompts Date: Fri, 16 Jan 98 14:14:51 +0100 Resent-Message-ID: <"x-r9N.0.Wx4.lNslq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3720 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu It looks (as I mentioned before) as if someone has rationalised the %l strftime sequence to do the same as in strftime(), i.e. print a space before a number less than 10 in an hour given in 12-hour format. Since this makes me shriek with frustration every time I look at my prompt, which is often, the best thing to do is probably the same as with the 24-hour version %k, where there is an additional sequence %K which suppresses the space. Luckily %L is free, so this makes the 12 and 24 hour versions nicely consistent. (Historically, both %k and %l suppressed the space, so this is also the natural way to update it.) *** Doc/Zsh/prompt.yo.%L Fri Jan 16 14:26:01 1998 --- Doc/Zsh/prompt.yo Fri Jan 16 14:26:23 1998 *************** *** 103,112 **** ) item(tt(%D{)var(string)tt(}))( var(string) is formatted using the tt(strftime) function. ! See manref(strftime)(3) for more details. Two additional codes are available: tt(%f) prints the day of the month, like tt(%e) but ! without any preceding space if the day is a single digit, and tt(%K) ! corresponds to tt(%k) for the hour of the day in the same way. ) item(tt(%l))( The line (tty) the user is logged in on. --- 103,113 ---- ) item(tt(%D{)var(string)tt(}))( var(string) is formatted using the tt(strftime) function. ! See manref(strftime)(3) for more details. Three additional codes are available: tt(%f) prints the day of the month, like tt(%e) but ! without any preceding space if the day is a single digit, and ! tt(%K)/tt(%L) correspond to tt(%k)/tt(%l) for the hour of the day ! (24/12 hour clock) in the same way. ) item(tt(%l))( The line (tty) the user is logged in on. *** Src/utils.c.%L Fri Jan 16 14:22:27 1998 --- Src/utils.c Fri Jan 16 14:41:30 1998 *************** *** 1318,1326 **** #else char *origbuf = buf; #endif - static char *lstr[] = - {"12", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", - "10", "11"}; char tmp[3]; --- 1318,1323 ---- *************** *** 1351,1357 **** *buf++ = '0' + tm->tm_hour % 10; break; case 'l': ! strucpy(&buf, lstr[tm->tm_hour % 12]); break; case 'm': *buf++ = '0' + (tm->tm_mon + 1) / 10; --- 1348,1359 ---- *buf++ = '0' + tm->tm_hour % 10; break; case 'l': ! case 'L': ! if ((tm->tm_hour % 12) > 10) ! *buf++ = '1'; ! else if (fmt[-1] == 'l') ! *buf++ = ' '; ! *buf++ = '0' + ((tm->tm_hour % 12) % 10); break; case 'm': *buf++ = '0' + (tm->tm_mon + 1) / 10; -- Peter Stephenson Tel: +39 50 911239 WWW: http://www.ifh.de/~pws/ Gruppo Teorico, Dipartimento di Fisica Piazza Torricelli 2, 56100 Pisa, Italy